the for loop is only giving me the last value

조회 수: 27 (최근 30일)
Othman Alkandri
Othman Alkandri 2022년 1월 19일
댓글: Star Strider 2022년 1월 19일
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
the cyclist
the cyclist 2022년 1월 19일
Can you upload the data, using the paperclip icon in the INSERT section of the toolbar?

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2022년 1월 19일
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
Othman Alkandri
Othman Alkandri 2022년 1월 19일
Thank you a lot
Star Strider
Star Strider 2022년 1월 19일
As always, my pleasure!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by