Creating a 365x24 matrix using for and if
Ältere Kommentare anzeigen
Hi!
I'm trying to create a numeric matrix. Every row is a day of the year and every collumn is an hour of the day, so the matrix's size is going to be 365x24.
i need all the sells to have the same value (-9999) and I need to to this using a loop in order to save time.
Here's what I've typed so far.
COSMY2014=zeros(size(COSMY2013));
i=1;
j=1;
for i < 366
for j < 25
if COSMY2014(i,j)=0
COSMY2014(i,j)=-9999;
end
j=j+1;
end
i=i+1;
end
I have created a matrix with the correct size but every cell's value is 0. What I'm trying to do in this piece of code is change every value to -9999 but when I run it nothing happens. I cannot find errors in the logic so I assume I've made mistakes in the syntax.
I really appreciate any help you can give me!
1 Kommentar
Stephen23
am 23 Jul. 2019
Assuming that COSMY2013 has the same size:
COSMY2014 = COSMY2013;
COSMY2014(:) = -9999
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!