the for loop is only giving me the last value

24 vues (au cours des 30 derniers jours)
Othman Alkandri
Othman Alkandri le 19 Jan 2022
Commenté : Star Strider le 19 Jan 2022
Hello guys, the for loop only gives me the last value of the .csv file. Some people have the same issue as mine seam. Most posts recommend adding a zero vector. I added the zero vector, but the problem is still remaining.
Data_table = readtable('20170401damlbmp_zone.csv')
Data_20170401 = readmatrix('20170401damlbmp_zone.csv')
% take the N.Y.K and North inromation from the loaded files
North_20170401 = zeros(360,6);
N_Y_K_20170401 = zeros(360,6);
for i = 10 :15 : 360
%for j = 1:1:24
disp( Data_20170401(i,3))
N_Y_K_20170401(i,1)= Data_20170401(i,3);
x= i+1;
North_20170401(i,1) = Data_20170401(x,3);
% end
end
  1 commentaire
the cyclist
the cyclist le 19 Jan 2022
Can you upload the data, using the paperclip icon in the INSERT section of the toolbar?

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 19 Jan 2022
There are likely a lot of zeros in the vectors because of the way ‘i’ is defined.
The loop is likely not necessary anyway.
Try something like this —
i = 10 : 15 : 360;
N_Y_K_20170401 = Data_20170401(i,3);
North_20170401 = Data_20170401(i+1,3);
.
  7 commentaires
Othman Alkandri
Othman Alkandri le 19 Jan 2022
Thank you a lot
Star Strider
Star Strider le 19 Jan 2022
As always, my pleasure!
.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by