I have a code which is definitely correct, but the loglog graph wont work properly.
Show older comments
clear all
x=linspace(-1,1,40);
t=linspace(0,1,20);
n=[5,10,20];
hold on
for i=1:3
U=(exp(-(pi.^2)*t(n(1,i)))+sin(t(n(1,i))))*sin(pi*x);
v=CN(n(1,i));
En(i)=max(abs(U-v));
end
loglog(n,En,'--')
hold on
loglog(n,n)
this is the graph I get

this is the graph i should get

2 Comments
Star Strider
on 8 Mar 2016
What’s ‘CN’?
John D'Errico
on 10 Feb 2024
Edited: John D'Errico
on 10 Feb 2024
It is definitely perfectly, absolutely correct, BUT, it does not work. Why does that seem to put the lie to your claim of correctness?
The point being, a simple definition of correctness of code, is that it works as designed, and it does what it is supposed to do.
Accepted Answer
More Answers (0)
Categories
Find more on Data Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!