for循环/功能
3 views (last 30 days)
Show older comments
Hi
I'm stuck on a certain problem I'm trying to solve.
I'm running a for loop with an array of 90 values. These values are passed to a function I created. I need to record every value that the function produces (I'm thinking within an array). I just cannot seem to work out how to do that.
I also have another for loop running with another 90 values, passed to the same function and need to do the same with these values.
The 2 sets of data then need to be put into a 2D array (I also can't seem to work this part out either). Am I best getting each data set into separate arrays first? Then into a 2D array? Am I also correct that these two data sets cannot be put into a 2D array unless they are the same size?
Thanks
Bob
1 Comment
Answers (1)
Wayne King
on 30 Nov 2011
There's no reason why you can't assign the output of a function to an array
% initialize an array
A = zeros(100,2);
fornn = 1:100
(nn, 1) = times(nn,nn+1);
A(nn,2) = sum(1:nn);
end
Is this what you asking?
4 Comments
Wayne King
on 30 Nov 2011
Given that I know absolutely nothing about your function(), I cannot possibly speculate on what the function is doing.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!