Problem on storing data in new table using for loop
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have snippet of code shown below:
I used for loop for every row and column and store each value in new table. I create new table as Newtable=zeros(10,100). When I run this code, each value from for loop iteration, the value is saved starting at column 12. I want to start from column 1 for each value to be stored using for loop. I don't know how to solve this? Any advice is appreciated.
NewTable=zeros(10,100);
for k=1:nrow
if tarray(k,2)==1
for m=12:ncol
for n=1:nrow
NewTable(n,m)=interp1(A(3:end,1),A(3:end,2),tarray(n,m));
end
end
0 commentaires
Réponses (1)
KSSV
le 1 Fév 2021
Modifié(e) : KSSV
le 1 Fév 2021
NewTable=zeros(10,100);
for k=1:nrow
if tarray(k,2)==1
for m=1:ncol % <---- start from m = 1
for n=1:nrow
NewTable(n,m)=interp1(A(3:end,1),A(3:end,2),tarray(n,m));
end
end
Also the above can be achieved with:
NewTable=zeros(10,100);
for k=1:nrow
if tarray(k,2)==1
for n=1:nrow
NewTable(n,:)=interp1(A(3:end,1),A(3:end,2),tarray(n,:));
end
Voir également
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!