首页 > 学院 > 开发设计 > 正文

Matlab总结贴2

2019-11-06 08:55:18
字体:
来源:转载
供稿:网友

PRogramming and Scripts

Sample Script

To create a script, use the edit command,

edit plotrand

Loops and Conditional Statements

Within a script, you can loop over sections of code and conditionally execute sections using the keyWordforwhile,if, and switch.

Now, modify the for loop so that you can view the results at each iteration.Display text in the Command Window that includes the current iteration number, and remove the semicolon from the assignment to sampleMean.

for k = 1:nsamples   iterationString = ['Iteration #',int2str(k)];   disp(iterationString)   currentData = rand(npoints,1);   sampleMean(k) = mean(currentData)endoverallMean = mean(sampleMean)


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表