MATLAB Answers

Converting flowchart to matlab code

12 views (last 30 days)
menaka malu
menaka malu on 18 Feb 2020
Commented: menaka malu on 22 Feb 2020
I have one flow chart with me regarding my work. Iam trying to convert the flowchart to matlab code. But iam facing some difficulties in loops. one loop is there for time increment. Time is starting from 0. And incrementing 0.0025s in each iteration. But end value of time is infinity. The end time is deciding by condition. Is x<y means iteration has to stop. how i will put the loop with while condition?

  0 Comments

Sign in to comment.

Accepted Answer

KSSV
KSSV on 18 Feb 2020
x = 0 ; % your initial x value
y = 100 ; % your fixed y value
t0 = 0 ; % initial time
dt = 0.00025 ; % time step
t = zeros([],1) ; % initilaize the time array
count = 0 ;
while x < y
count = count+1;
t(count) = t0+(count-1)*dt ;
% calculate x
x = rand*100+rand ; % this is for demo
end

  1 Comment

menaka malu
menaka malu on 22 Feb 2020
Thankyou for trying this. I will try this way

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags


Translated by