Hey, I've got a problem plotting a function in Matlab.
I first run this:
f = inline('-x.^2');
for i = 0:10
[I(i+1) h(i+1) tid(i+1)] = trapets(f,0,1,2^i);
trunk = I - log(2);
t = -7:0;
c = polyfit(log(h),log(trunk),1);
yy = polyval(c,t);
koefficienter = real(c)
and after that I run this file:
axis([0 0.6 0 0.0014])
Thing is, I don't get any errors, and the plot windows pops up with axes and all, but there is no graph to be found. It's just an empty window with two axes.
Anyone got any ideas?
Okay, so I'm new to this site and couldn't find the reply button, so I add a reply here instead.
I just realized that I hadn't given you all the information for this problem.. Sorry about that, anyhow I would really appreciate it if someone had the time to help me with this, it would seriously make my week.
This is the part I accidentally left out:
function [ I,h,tid ] = trapets(
I = I+2*f(a+k*h);
for k = 1:2:n-1
I = I + 4*f(a+k*h);
I = I * h/3;
tid = toc;
Edit 2: So, I think that the graph I'm seeking is actually getting plotted in the first code that I wrote, the problem is that the variabe 'I' is not changing, which I expect it to do, although the variabels 'n' and 'h' do change. If 'I' was working correctly, I would probably get the right graph (hopefully). Any ideas, anyone?