How can I get a matrix to store all of the for loop results?
Show older comments
I would like a final matrix with all of the values of t, but I keep getting an error. Here is my code and the error:
DataRate=4;
TotalPts=14401;
Xmult=.016667;
t=0;
for i=1:TotalPts
t(i)=t+ Xmult/DataRate;
end
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in CE_Alz (line 10) t(i)=t+ Xmult/DataRate;
I understand t, Xmult, and DataRate are all scalar values, but I would like a matrix to be created from the initial t value. What am I doing wrong?
Accepted Answer
More Answers (1)
Roger Stafford
on 19 Feb 2014
Edited: Roger Stafford
on 19 Feb 2014
A more compact way:
s = Xmult/DataRate;
t = s:s:s*TotalPts;
Categories
Find more on Loops and Conditional Statements 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!