Repeating for loop until getting a list of solution

1 view (last 30 days)
Abdullah Al Shereiqi
Abdullah Al Shereiqi on 17 Mar 2020
Hi to all
I'm not that good in Matlab and I tried to learn it. I used for loop to create a solution for each value of (n) and repeating the for loop. The for-loop is from 1 to 8760 while n is from 0 to 1 with increament of 0.1.
I want to repeat the for-loop for each (n) and finally make a vecto of [n, solution from for-loop]. Attached flow chart may explain more about what I want.
  6 Comments
Sriram Tadavarty
Sriram Tadavarty on 17 Mar 2020
You could even break when s is greater than 1, example, the condition of if s > 1, can be placed, rather than s == 1 to deal with tolerance issues.
Or it can be directly placed a loop for 100 times, in each time 0.01 can be added.

Sign in to comment.

Answers (2)

Guillaume
Guillaume on 17 Mar 2020
If it's a flow chart you've been given, then you are entitled to complain loudly. That flow chart is very misleading. The layout is a more representative of a while loop than a for loop.
This is what you're meant to do:
for n = 0:0.1:1 %represented by 4 boxes on the flow chart! (n = 0, for-loop, n=1?, increment by 0.1)
%do calculation inside the loop (1 box on the chart)
end
%get a vector of solution (1 box on the chart)

Abdullah Al Shereiqi
Abdullah Al Shereiqi on 17 Mar 2020
Thanks to all of you; Saruram , Rik and Guillaume.
It seems working fine after using another for-loop (100 times).
Appreciated your support and guidance

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by