Matlab编程与工程应用第二版习题解答全Word格式.docx
- 文档编号:17457668
- 上传时间:2022-12-01
- 格式:DOCX
- 页数:37
- 大小:23.72KB
Matlab编程与工程应用第二版习题解答全Word格式.docx
《Matlab编程与工程应用第二版习题解答全Word格式.docx》由会员分享,可在线阅读,更多相关《Matlab编程与工程应用第二版习题解答全Word格式.docx(37页珍藏版)》请在冰豆网上搜索。
t=100;
V=50;
wcf=35.7+0.6*t-35.7+0.16*V+0.43*t*0.16*V
wcf=
412
14.
Fix<
3.5>
=3;
Floor<
3.4>
Fix<
-3.4>
=-3;
3.2>
-3.2>
=-4;
Ceil<
15.
Sqrt<
19>
3^1.2
Tan<
pi>
16.
Intmin<
‘int32’>
;
intmax<
intmin<
‘int64’>
intmax<
17.
Realmin<
‘double’>
Realmax<
18.
DblNum=33.8;
int32Num=int32<
DblNum>
int32Num=
34
19.
A1=rand;
A2=20*rand;
A3=30*rand+20;
A4=round<
rand*10>
A5=round<
rand*11>
/
A6=round<
rand*50>
+50;
A4=randi<
10>
A5=randi<
11>
A6=randi<
50>
20.略
21.
Double〔‘A’<
Double<
‘a’>
所以大写在前,小写在后;
22.
CharNum='
xyz'
CharNum=char<
CharNum-2>
CharNum=
vwx
23.
vec=[3:
1:
6]
vec=
3456
vec2=[1.0000:
0.5000:
3.0000]
vec2=
1.00001.50002.00002.50003.0000
vec3=[5:
-1:
2]
vec3=
5432
24.
vec1=linspace<
4,8,3>
vec1=
468
vec2=linspace<
-3,-15,5>
-3-6-9-12-15
vec3=linspace<
9,5,3>
975
25.
vec=[1:
10]
12345678910
vec=linspace<
1,10,10>
vec2=[2:
5:
12]
2712
2,12,3>
26.
myend=randi<
4>
+8;
vec1=[1:
3:
myend]
14710
27.
vec=[-1:
0.2:
1]'
-0.8000
-0.6000
-0.4000
-0.2000
0
0.2000
0.4000
0.6000
0.8000
1.0000
28.
vec=[0:
15];
n=[1:
2:
numel<
vec>
-1];
vec2=vec<
n>
02468101214
29.
function[ab]=PI_CONT<
x>
%UNTITLEDSummaryofthisfunctiongoeshere
%Detailedexplanationgoeshere
n=1:
fix<
numel<
/2>
a=x<
n=1+fix<
/2>
:
b=x<
end
rem<
2>
30.
rand<
2,3>
10*rand<
5+round<
15*rand<
randint<
2,3,[515]>
31.
rows=randi<
5>
cols=randi<
y=zeros<
rows,cols>
32.
mat=[78910
121086];
A1=mat<
1,3>
A2=mat<
2,:
A3=mat<
:
1:
2>
33.
mymat=[234;
567]
mymat1=fliplr<
mymat>
mymat2=flipud<
mymat3=rot90<
34.
mymatzero=zeros<
4,2>
mymatzero<
=[3,6]
35.
x=linspace<
-pi,pi,20>
y=sin<
36.
randmat=randint<
3,5,[-55]>
sign<
randmat>
37.
4,6,[-55]>
randmat2=abs<
38.
randmat=rand<
3,5>
randmat<
3,:
=[]
39.
vec=1:
1:
1000;
vec<
end>
[ab]=size<
a*b>
40.
同上
41.
mat=zeros<
mat<
:
1>
=zeros<
42.
myc=clock
today=myc<
1:
3>
now=myc<
4:
6>
now=fix<
now>
第二章MATLAB程序设计概述
ri=2;
%Radiusinternal
ro=4;
%Radiusouter
V=4*pi/3*<
ro^3-ri^3>
%calculatevolume
%CalculateAtomicWeightH2O2
Weight_O=15.9994;
Weight_H=1.0079;
AtomicWeight=Weight_O*2+Weight_H*2%CalculateH2O2AtomicWeight
fprintf<
'
LengthofThecharacterstringis:
%d\n'
…
length<
input<
Pleaseinputcharacterstring:
\n'
'
s'
4.
NewNumber=input<
pleaseinputaNumber:
Numberwith2decimalis:
%0.2f\n'
NewNumber>
vec=input<
Enteramatrix:
'
[1:
10;
10]
6.
fprintf<
OUTPUT:
%f\n'
12345.6789>
12345.678900
%10.4f\n'
12345.6789
%10.2f\n'
12345.68
%6.4f\n'
%2.4f\n'
7.
12345>
12345
%5d\n'
%8d\n'
%3d\n'
x=12.34;
y=4.56;
xis%.3f\n'
x>
xis12.340
xis%0.0f\n'
xis12
yis%0.1f\n'
y>
yis4.6
yis%0.1f!
yis4.6!
%CalculateAreaofthesquareness
TheAreaofTheSquarenessis%.2f'
<
PleaseinputtheLengthoftheSquareness\n'
…
*<
PleaseinputtheWidthoftheSquareness\n'
10.
NewName=input<
Whatisyourname?
Wow,yournameis%s!
NewName>
11.
NewString=input<
Enteryourstring:
YourStringwas:
%s'
NewString>
WaterSpeed=input<
Enterthefolwinm^3/s:
WaterSpeedft=0.028\WaterSpeed;
Aflowrateof%.3fmeterspersec\n'
WaterSpeed>
isequivalentto%.3ffeetpersec\n'
WaterSpeedft>
13.
IncomeY=input<
Inputyourincomeeveryyear?
FoodCostY=[IncomeY*8/100IncomeY*10/100];
FoodCostM=12\FoodCostY;
FoodCostineveryyearis%.2f-%.2f\n'
FoodCostY<
1>
FoodCostineveryMonthis%.2f-%.2f\n'
FoodCostM<
14.
Weight=input<
PleaseinputtheWeightoftheplan\n'
Area=input<
Pleaseinputtheareaoftheplanwing\n'
ChargeofPlanWinis%.2f\n'
Weight/Area>
x=10;
y=10;
plot<
x,y,'
g+'
16.
clf
x=-2:
0.1:
2;
y=exp<
g'
xlabel<
X'
ylabel<
Y'
legend<
Exp<
Title<
ExpExample'
x=1:
5:
100;
y=sqrt<
go'
holdon;
bar<
x,y>
y=randint<
1,100,[0100]>
length<
y>
ro'
holdon
figure<
k'
19.
x=linspace<
0,pi,10>
y=sin<
r'
0,pi,100>
b'
20.
loadTimeTemp.dat
x=TimeTemp<
y=TimeTemp<
Xlabel<
Height'
Ylabel<
Temperature'
Height-Temperature'
TEMP'
randint<
3,6,[50100]>
saveRandInt.batans-ascii;
2,6,[50100]>
saveRandInt.batrandint-ascii–append
loadRandInt.bat
RandInt
loadtesttan.bat
tan<
testtan>
loadhightemp.dat
hightemp<
=hightemp<
.+1900
savey2ktemp.dathightemp–ascii
function[fn]=fn<
x>
%Calculateyasafunctionofx
fn=x^3-4*x^2+sin<
25.
function[mwh]=mwh_to_gj<
%conversfromMWhtoGJ
mwh=3.6*x;
function[output_args]=miletometer<
%Convermiletometer
Mile=input<
mileperhoursnumber:
meter=Mile*5280*0.3048/3600;
output_args=meter;
Meterofthemileis:
%.2f'
meter>
function[Tn]=Interest<
p,i,n>
%UNTITLED4Summaryofthisfunctiongoeshere
Tn=p*<
1+i>
*n;
略
function[V]=SpeedConv<
pi,ps>
V=1.016*sqrt<
pi-ps>
30.function[THR]=Cal_rate<
A>
THR=<
220-A>
*0.6;
function[nJ]=STL_calc<
nJ=sqrt<
2*pi*n>
*<
n/exp<
^n;
function[output_args]=costn<
n>
%UNTITLED5Summaryofthisfunctiongoeshere
output_args=5*n^2-44*n+11;
n=input<
Enterthenumberofunits:
Cn=costn<
Thecostfor100unitswillbe$%.2f\n'
Cn>
略〔仿造32题
function[V]=oblong<
length>
%UNTITLED8Summaryofthisfunctiongoeshere
V=1/12*sqrt<
*length^3;
Thevolumeofoblongis:
%.2f\n'
oblong<
Enterthelengthoftheoblong:
35.
function[y]=pickone<
%pickone<
returnsarandomelementfromvectorx
n=length<
y=x<
randi<
36.
function[y]=vecout<
%UNTITLED11Summaryofthisfunctiongoeshere
y=x:
x+5;
37.
b=input<
Enterthefirstside:
c=input<
Enterthesecondside:
afa=input<
Entertheanglebetweenthem:
b^2+c^2-2*b*c*cos<
afa*<
pi/180>
Thethirdsideis%.3f\n'
38.
loadfloatnums.dat
floatnums=round<
floatnums>
floatnums=floatnums'
saveintnums.datfloatnums-ascii;
loadcostssales.dat
n=length<
costssales<
Therewere%dquartersinthefile'
n>
n=1:
n;
costs=costssales<
sales=costssales<
n,costs,'
ko'
n,sales,'
b*'
COSTS'
SALES'
COST'
SALE'
title<
COST-SALE'
costssales=costssales'
costssales=flipud<
costssales>
savenewfile.datcostssales-ascii;
第三章选择语句
2.if<
pleaseEnterax:
~='
x'
disp<
sorrythecharnotx'
3.functiony=Test3<
if<
x==12>
y=1;
else
y=x+1;
end;
4.disp<
Theprogramwillcalculatethevolumeofapyramid'
a=input<
Enterthelengthofthebase:
Isthatiorc?
if<
c=='
c'
a=a/2.54;
Enterthewidthofthebase:
b=b/2.54;
d=input<
d=d/2.54;
TheVolumeofthePyramidis%.3fcubicinches.'
a*b*d/3>
Areyouanengineer?
Y/N>
==
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Matlab 编程 工程 应用 第二 习题 解答
![提示](https://static.bdocx.com/images/bang_tan.gif)