the for loop is only giving me the last value

20 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

更多回答(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