MATLAB第六次上机实验报告

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

MATLAB第六次上机实验报告

0210901班学号2009210811 姓名:李贤凤Quiz 3.1

>> a=20;

>> b=-2;

>> c=0;

>> d=1;

>> a>b

ans =

1

>> b>d

ans =

>> a>b&c>d

ans =

>> a==b

ans =

>> a&b>c

ans =

>> ~~b

ans =

1

>> a=2;

>> b=[1 -2;-0 10];

>> c=[0 1;2 0];

>> d=[-2 1 2;0 1 0];

>> ~(a>b)

ans =

0 0

0 1

>> a>c&b>c

ans =

1 0

0 1

>> c<=d

??? Error using ==> <=

Matrix dimensions must agree.

>> a=2;

>> b=3;

>> c=10;

>> d=0;

>> a*b^2>a*c

ans =

>> d|b>a

ans =

1

>> (d|b)>a

ans =

>> a=20;

>> b=-2;

>> c=0;

>> d='Test';

>> isinf(a/b)

ans =

>> isinf(a/c)

Warning: Divide by zero.

(Type "warning off MATLAB:divideByZero" to suppress this warning.)

ans =

1

>> a>b&ischar(d)

ans =

1

>> isempty(c)

ans =

Quiz3.2

1.% Script file : Sqrt_x.m

% Purpose:

% This program is used to calculate the square root of a randem number

% Record of revisions:

% Date Programmer Description of change % === ======== ================ % 10/22/2010 lixianfeng Original code

% Define variables :

% x --x is a randem number

% y --y is a function of the sqrt(x)

% Prompt the user for the value x

x=input('Enter the number of x:');

% Calculate the function sqrt(x)

if x>=0

y=sqrt(x);

fprintf('The square root of x is:%f',y);

else

disp('It is an error message about the square root function ');

disp('The value of sqrt is 0');

end

example:test a

Enter the number of x:5

The square root of x is: 2.236068

Enter the number of x:-2

It is an error message about the square root function

The value of sqrt is 0

2. % Script file : Scores.m

% Purpose:

% This program is used to calculate the numerator / denominator

% Record of revisions:

% Date Programmer Description of change

% ==== ========== =================== % 10/22/2010 Li xianfeng Original code

% Define variables :

% fun --fun is calculated as numerator / denominator

% Prompt the user for the value numerator and denominator

numerator=input('Enter the numerator:');

denominator=input('Enter the denominator:');

% Calculate the function numerator / denominator

if abs(denominator)>=1.0E-300

fun=numerator / denominator ;

fprintf('The numerator / denominator is:%f',fun);

else

相关文档
最新文档