I have now changed the code bc the slope that was plotted was wrong. I created a matrix y to plot against x, instead of calling the function in plot(f(x). However the plot then disappeared again..
I have colons for x this time, have i missed something else?
clear all, close all, clc
matris=[]
diffmax=100
x=0:diffmax
for i=1:diffmax
y=f(x(i))
matris=[matris;y]
end
plot(x, y)
hold on
xlabel('x')
ylabel('velocity')
axis([0 diffmax 0 30])
function velocity=f(x)
if x>75
velocity = 25;
disp('rad 18')
else
velocity = x/3;
disp('rad 21')
end
end