filling matrix instead of using for loops
Show older comments
Hi,
I want to fill my Matrix in following way.
I have 2 vectors that are used by my Matrix. Say
VectorA = 1:10;
VectorB = 20:29;
And I want to use them to fill my matrix.
for m = 1:10
for n = 20:29
MatrixK = [sin(m),cos(n);cos(n).*sin(m),exp(m)];
% MatrixK will be used here
end
end
However, as you know, it is not efficient as these 2 for loops have to be run by 100x100 times. How can I do it efficiently? I am not sure I have fully defined my problem. Most likely, I will add sth.
Thanks
Accepted Answer
More Answers (0)
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!