MATLAB: I have some problem when plotting the graph, anyone can help? Thanks

for loop

This is my code
for x = -10:10
y = 2^(0.4*x)+5
plot(x,y,'g')
end

Best Answer

Hi,
You need to store y first.
x = -10:10;
for i = 1:numel(x)
y(i) = 2^(0.4*x(i))+5
end
plot(x,y,'g')