FOR LOOP MATLAB
Ältere Kommentare anzeigen
Guys I am so sorry i didn't the complete the question before, i was thinking if i can just get started i will be able to continue but i am more confused now...
The full question is: Write 4 lines of code to use a forloop in the variable i to calculate and store the values of t and h=(3+t)t. Continuing with the above and assuming the out variable is h, allocate memory with NaN command for t and h. b. Next we want to change the problem to calculate 3 equations in the same for loop above. The input will still be t but now the 3 output equations are: h1=10cos(t) h2=t+2 h3=sin(t) Assuming we have allocated memory for h1,h2 and h3, what would the new code for the body of the loop be?
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 4 Aug. 2011
For the first part:
for i = 1
t = t;
h = (3+t)*t;
end
Perhaps you omitted key parts of the question that described what t is, or how far many iterations the loop was supposed to go?
3 Kommentare
Oluakin
am 4 Aug. 2011
Walter Roberson
am 4 Aug. 2011
That is the same question as you originally posted. It asks you to calculate t, but does not give any information about how t is to be calculated.
To finish the question *in the form posted*, after the "for" loop, add the two statements,
t = nan;
h = nan;
I do not understand the point of allocating memory for h *after* the loop instead of *before* the loop, but the allocating the memory _before_ the loop would not be "continuing on" as the question requires.
Oluakin
am 4 Aug. 2011
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!