I have the following code. The values of displ in stage1 and stage2 are plotted in displ vs time graph. Thus a single curve is obtained.
Show older comments
displ=zeros(100,2)
tim=zeros(100,1)
for i=2:100
v=5;
dt=1*10^-4;
function [displ_f]=stage1(displ_i)
dt=1*10^-4;
v=5;
displ_f=displ_i+v*dt;
endfunction
function [displ_f]=stage2(displ_i)
dt=1*10^-4;
v=5;
displ_f=displ_i+v*dt;
endfunction
if (displ(i-1,1)<0.020 && displ(i-1,2)>=0)
disp("IN stage 1");
[displ(i,1)]=stage1(displ(i-1,1));
displ(i,2)=v;
tim(i,1)=tim(i-1)+dt;
elseif (displ(i-1,1)>=0.020 && displ(i-1,1)<=0.0256 && displ(i-1,2)>=0)
disp("IN stage 2");
[displ(i,1)]=stage2(displ(i-1,1));
displ(i,2)=displ(i-1,2);
tim(i,1)=tim(i-1)+dt;
end
end
disp(" displ vs tim")
plot(tim(:,1),displ(:,1));
How will I get stage1 curve in orange color and stage2 curve in blue color in the same plot to know which stage has which displ values?
5 Comments
madhan ravi
on 7 Jan 2019
Edited: madhan ravi
on 7 Jan 2019
it’s clearly related to octave
Lakshmikruthiga Ponnusamy
on 7 Jan 2019
>>help endfunction
endfunction not found.
>>
Happy to help: Please define your strange "endfunction" function.
Is it perhaps not Matlab?
.
There's an old Irish proberb that is about asking an Irish guy how to get to a destination. He simply answers that he wouldn't start from here.
Lakshmikruthiga Ponnusamy
on 8 Jan 2019
Walter Roberson
on 8 Jan 2019
Octave is a product of the Free Software Foundation . The fundamental principle of FSF is that the software should be no cost, and that you can modify it as needed , but that if you want service then you should pay for the service . Therefore if you are not satisfied with the response you got from the Octave distribution list, you should be hiring a consultant . That is the FSF way .
FSF is not a charity to provide free software because software can be hard to afford .FSF is a deliberately disruptive economic model that aims to drive proprietary software out of business, replacing it with no cost for the software and instead charging for work on the software.
FSF says that it is morally and ethically wrong to create software and not give the software away for no charge, that anyone who creates proprietary software is a Bad Person who is Doing Evil.
Accepted Answer
More Answers (0)
Categories
Find more on Octave 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!