资源描述:
《matlab四合一(dream)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第一题目的:1)学会使用矩阵和向量的思维方式来考虑问题。这是因为Matlab以该种方式组织数据,通过这种方式,一个复杂运算在选择了合适的函数和数据组织方式基础上,往往可以通过1~2行代码解决。2)学会和习惯使用help来学习新的函数用法。需要用到的函数本文在题目后面标出。题目说明:问题1-7请新建一个脚本,命名为shortProblems.m,7道小题目之间以注释隔开。B3031.标量变量生成,请生成如下变量:2.向量生成,请生成如下向量变量:3.矩阵变量,请生成如下矩阵变量:4.标量方程,使用题目1中生成的变量计算x,y和z值:5.向量方程计算,使用题目2中生成的变量求解以下方
2、程的值。使用元素对应法则,.*,./,.^。6.矩阵运算,使用题目2和3中生成的变量求解以下方程:7.一般运算及元素索引shortProblemclearall;a=10;b=2.5*10^23;c=2+3*i;d=exp((j*2*pi)/3);%%%%%%%%%%%%%%%%%%%%%%aVec=[3.1415926];bVec=ceil[2.71828182];cVec=length[5-0.25];dVec=logspace[01101];eVec='Hello';%%%%%%%%%%%%%%%%%%%%%%%%n=ones(9)aMat=n*2bMat=zeros(9)
3、diag([123454321])cMat=reshape(p,10,10)dMat=nan(34)eMat=[13-15;-2210-87]fMat=round(rand(5,3)*6)-3%%%%%%%%%%%%%%%%%%%%%%%%%%%x=1/(exp(-(a-15)/6))y=(a^(1/2)+b^(1/21))^piz=(log(real[(c+d)*(c-d)]*sin(a*pi/3))/(conj*con(-j))%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%xVec=(1/((2*pi*2.5^2)^0.5))*exp((-cVec^2)
4、/(2*2.5^2))yVec=((aVec')^2+b*Vec^2)^0.5zVec=log10(1/dVec)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%xMat=(aVec*bVec)*aMat^2yMat=bMat*aMatzMat=det(cMat)*(aMat*bMat)'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%sum=cSum(cMat)mean=eMean(eMat)'eMat=[111;-2210-87]cSub=cMat([29;92])lin=[1120]lin=-1*lin[2220]find=(r
5、(15)<0.5)find=0%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%8.绘制曲线练习结果参考下图:twoLinePlotfiguret1=0:0.01:2*pi;y1=sin(t1);plot(t1,y1);axis([06-11])line([06],[00],'color','k')line([00],[-11],'color','k')xlabel('Time(s)'),ylabel('Functionvalue');title(['SinandCos'])legend('sin','cos',0)holdon;%%%%%%%%%%%%%
6、%%%%%%%%%%%%t1=0:0.01:2*pi;y2=cos(t1);plot(t1,y2,'r--')axis([06-11])line([06],[00],'color','k')line([00],[-11],'color','k')xlabel('Time(s)'),ylabel('Functionvalue');title(['SinandCos'])legend('sin','cos',0)holdoff;9.变量操作运行结果应是这样的:calculateGradesclearall;x=xlsread('testdata.xls')ans=x(1:5,:)gr
7、ades=x(:,2:end);ans=mean(grades)meanGrades=nanmean(grades)meanMatrix=repmat(meanGrades,size(grades,1),1)curvedGrades=3.5*(grades./meanMatrix);ans=nanmean(curvedGrades)curvedGrades(find(curvedGrades>5))=5;totalGrades=ceil(nanmean(curvedGrades'