ploting in for loop
古いコメントを表示
I wrote sum which is xs for below calculation There is something wrong with my code below that i can not figure it out?
clc
t=cputime;
k=0;
for p=1:1:7
dt=10^-p;
k=0:1.35/dt;
xs = 2/(sqrt(pi))*sum(exp(-(k*dt).^2)*dt)
e=cputime-t;
semilogx(e,dt)
end
採用された回答
その他の回答 (1 件)
Daniel kiracofe
2016 年 11 月 13 日
編集済み: Daniel kiracofe
2016 年 11 月 13 日
"there is something wrong" is pretty vague, so I'm totally guessing at what your problem is. But this seems like a reasonable guess. If this doesn't answer you question then you need to post more detail about what is your specific problem.
clc
t=cputime;
k=0;
for p=1:1:7
dt(p)=10^-p;
k=0:1.35/dt(p);
xs = 2/(sqrt(pi))*sum(exp(-(k*dt(p)).^2)*dt(p))
e(p)=cputime-t;
end
semilogx(e,dt)
2 件のコメント
Ahmet Oguz
2016 年 11 月 14 日
Walter Roberson
2016 年 11 月 14 日
I would make a small change, and move the
t=cputime;
to inside the for p loop. Otherwise you are getting cumulative time since you started, instead of time for that particular refinement.
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!