Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Pb in plotting for loop, in get juste the laste one

1 回表示 (過去 30 日間)
Touts Touts
Touts Touts 2019 年 4 月 13 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hy : for my plotting for loop i get juste the laste ones :
clc; clear all; close all
%
P_File = 'Get_';
E_File = '*.txt';
H_File = 6;
for i = 1:2;
flist = dir([P_File,num2str(i),E_File]);
for j = 1:length(flist);
disp('----')
fid = fopen(flist(j).name,'r');
MData{i} = textscan(fid,'%d%f%f%f','headerlines',H_File);
[C1 C2 C3 C4] = MData{i}{:};
[C1_1 C1_2 C1_3 C1_4] = MData{1}{:};
V_Position = unique(C1_1);
V_Time = unique(C1_2);
N_Position = length(V_Position); % Nbr Position
N_Time = (length(V_Time))-1; % Nbr out Time
for k = 1:N_Position;
L_Min(k) = ((N_Time+1)*(k-1))+1; % position min
L_Max(k) = ((N_Time+1)*k); % position max
Inf1{k} = C3(L_Min(k):L_Max(k));
end
plot(V_Time,Inf1{k})
hold on;
end
end
fclose('all');
Please where is the pb?

回答 (1 件)

Kevin Rawson
Kevin Rawson 2019 年 4 月 13 日
You are only getting the last ones because your plot command is outside the k for loop.
  3 件のコメント
Touts Touts
Touts Touts 2019 年 4 月 13 日
Dear Kevin Rawson any help please
Kevin Rawson
Kevin Rawson 2019 年 4 月 14 日
As I stated above, it's because you don't have the plot (and hold on) within your for k = 1:N_Position loop.
By putting your plot command outside of the for loop, you only plot a single instance, i.e. k=N_Position.

Community Treasure Hunt

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

Start Hunting!

Translated by