Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-12-14, 20:46   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 matlab-错误:索引必须为正整数或逻辑-如何制作电影

我有这个Matlab代码,它给了我标题上的错误。

% solution of the scalar wave 1d equation time=1000; steps=1000; a=input('Please enter the value of the ratio cdt/dx :'); %preallocate matrix u u=zeros(steps,time); %fill matrix u for i=1:time-1 for j=1:steps-1 if (i==1) u(j,i)=1; EDITED-->>from u(j,i)=0 % initial condition else EDIT -->> j==1 and i==1 becomes j==2,i==2 if (j==2 && i>=2 && ihere is the error end end end end for k=1:steps EDIT--> if mod(i,100)==0 figure(i/100) plot(u(:,i+1)) plot(u(k,1:100)) plot(u(k,1:200)) plot(u(k,1:300)) plot(u(k,1:400)) .... end 另外,如何才能更有效地编写最后一个循环(包含情节)以及如何制作电影?编辑->已解决



回答:

当i和j = 1时,u(j,i-1)和u(j-1,i)未定义;请记住,MATLAB矩阵索引从1开始,而不是0。



更多&回答...
poster 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 23:48


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.