Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
For-loop: create new name and extract data
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
So I have the following code below and am trying to use a 'for loop' to simplify. I am guessing have to use two sets of for loop but I am lost at the moment.
I have a dNPP which is matrix with 20 values.
NPP_2001 = [dNPP(1:1)];
NPP_2002 = [dNPP(2:2)];
NPP_2003 = [dNPP(3:3)];
NPP_2004 = [dNPP(4:4)];
NPP_2005 = [dNPP(5:5)];
NPP_2006 = [dNPP(6:6)];
NPP_2007 = [dNPP(7:7)];
NPP_2008 = [dNPP(8:8)];
NPP_2009 = [dNPP(9:9)];
NPP_2010 = [dNPP(10:10)];
I am thinking something along the line like this;
for k=2001:2010
for j=1:10
end
end
Any help would be appreciated
0 Kommentare
Antworten (1)
Joseph Cheng
am 23 Jul. 2014
How do you get 20 values? as dNPP(n:n) is just dNPP(n). or does this continue to dNPP(20:20)?
Also I would way this isn't a simplify way of coding. I would suggest you use a single variable to represent these such as dNPP. or rename it as NPP_20XX. where NPP_20XX(10) would equal NPP_2010;.
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!