- Most efficient way:
I want to store data in a matrix from a for loop using non integer indexing
1 次查看(过去 30 天)
显示 更早的评论
Here is the simple version of my code.
x = [5:0.1:20];
for v = 1:.1:10
R = v.*x;
mat(v,:)=R;
end
I want to store data in a matrix 'mat' for each iteration . Please suggest me how to do this.
0 个评论
采纳的回答
Sulaymon Eshkabilov
2020-8-15
Hi,
There are several ways of doing it:
x = [5:0.1:20];
v = (1:.1:10)';
MAT=v.*x;
2. Least efficient way:
for ii=1:numel(v)
MAT(ii,:)=v(ii)*x;
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!