Saving in 3d matrix Input and Output results from loop
2 views (last 30 days)
Show older comments
Dear all,
I'm quite new to matlab and having problems saving input and output data from a loop. What I'm doing is to run a function changing its three main parameters one at the time, A, B and C, this way:
if true
for A = 1:50;
for B = 1:0.05:200;
for C = 1:300;
[R] = myfunction (A,B,C)
end
end
end
end
The complete code works fine, but I need to save in a 3d matrix the output R AND each value of A, B and C for the corresponding output. Can you help me with an example?
Thanks in advance!
A
0 Comments
Answers (1)
Star Strider
on 2 May 2015
A cell array is the best option:
k1 = 0;
for A = 1:50;
for B = 1:0.05:200;
for C = 1:300;
k1 = k1 + 1;
[R] = myfunction (A,B,C)
RABC{k1} = {R, A, B, C};
end
end
end
I arbitrarily called the cell array ‘RABC’. It uses a simple counter to increment it.
10 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!