Effacer les filtres
Effacer les filtres

I want to store data in a matrix from a for loop using non integer indexing

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 15 Août 2020
Hi,
There are several ways of doing it:
  1. Most efficient way:
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

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by