12-07-2015 04:43 AM
Hi all,
I have a problem when using while loop inside mathscipt used inside control & simulation loop.
I want to read a excel cell each 5 seconds and to do it I'm using matlab scrip to know when I have to change cell.
My inputs on mathscipt are: run_time and sim_time. 1st one is the running time from control & simulation loop and 2nd is the time of each simulation.
My output is cell to go to the VI excel reader.
So, to do it I'm using a while loop like this:
cell=H1; % starting on excel cell H1
count=1; % creating and starting counter variable
h=5; % creating and starting second counter
while run_time < sim_time do % while loop: do it until reach simulation time.
if run_time ==h % compare running time with next 5 second (5,10,15,20,...)
count = count +1; % increase counter for next 5sec
h=h*count; % to compare on "if" next loop (5+5, 10+5, 15+5,....)
cell=strcat('H',int2str(count)); % put on ouput next cell: H2,H3...
end
end
But, when I used while loop it doesn't do nothing. My code is working without while loop, but it only does 2 cells. I want more than that.
Is there anyone can help me with it? another way to do it?
Thanks in advance.
Regards.
Marco
12-09-2015 02:23 AM
Hi MarcoAlmeida,
Did you try step by step debugging ?
If yes, what happen inside your while loop ?
Regards
12-09-2015 04:04 PM
12-15-2015 11:03 AM
Hi again.
I tried to do it but it seems to be dificult to me to understand what is going on inside loop because Vi is too big with multiples sub-vi's.
I got another way to do what I want.
Thanks anyway.
I have another problem reading excel files: my simulation gets too low but I'll try to do a search for same problem in another topic.
Regards
Marco