Trying to plot a function 2 times(once with x1,x2 = -2,2 , second with x1,x2 = -1,2) with the code below;however, only the second plot shows:
% We set the domain to [x1,x2];
x1 = [-2,-1]
x2 = [2,2]
% We plot the graphs
for i = 1:length(x1)
[domain,range,plot] = vector(x1(i),x2(i))
end
function [x,y,fplot] = vector(a,b)
x = [linspace(a,b)]
f = @(x) x.^2
y = f(x)
fplot = plot(x,y)
end
hold on, it will replace the previous ploty = x.^2?figurein the loop works. @ThomasSablik, didn't know that, it clears some space, thank you