フィルターのクリア

Plot with loop work only for the last

7 ビュー (過去 30 日間)
Ferial Assmani
Ferial Assmani 2016 年 3 月 29 日
コメント済み: Ferial Assmani 2016 年 4 月 1 日
Dear all, on a loop (i=1:Nbr_Position) I get only the last plot
V_Time = [1, 2, 3]; % Time Vector fixe length
%
V_Data = 1:1:12; % Data Vector
Nbr_Position = 2; % Nbr of position
Nbr_Case = 2; % Nbr of cases
%
N_Rows= length(V_Time); % Nbr of rows for matrix
N_columns= length(V_Data)/N_Rows; % Nbr of columns for matrix
M_Brut= (reshape(V_Data,[N_Rows,N_columns])); % Brut matrix from Data Vector
%
%
for i=1:Nbr_Position % loop by position
M_Nett{i} = M_Brut(:,(i):(Nbr_Position):(end)); % Nett matrix
for j=1:Nbr_Case % loop by case
plot(V_Time,M_Nett{i}(:,1:j)') % plot pair
title(['Position N°: ' num2str(i)]) % title
legend(genvarname(repmat({'Case'},1,j),'Case')) % legend
end
end
Why i cannot get the plot for i = 1 and i = 2 ?????

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 29 日
  4 件のコメント
Ferial Assmani
Ferial Assmani 2016 年 3 月 29 日
Coup d'un magicien, Merci beaucoup
Ferial Assmani
Ferial Assmani 2016 年 4 月 1 日
Dear Mr Azzi, for reason of clarity, i want to plot separately all figures, thy mast be (Nbr_Position * Nbr_Case) plot, i have tried this but it does not work:
clear all; clc; close all;
V_Time = [1, 2, 3]; % Time Vector fixe length
%
V_Data = 1:1:12; % Data Vector
Nbr_Position = 2; % Nbr of position
Nbr_Case = 2; % Nbr of cases
%
N_Rows= length(V_Time); % Nbr of rows for matrix
N_columns= length(V_Data)/N_Rows; % Nbr of columns for matrix
M_Brut= (reshape(V_Data,[N_Rows,N_columns])) % Brut matrix from Data Vector
%
%
for i=1:N_columns % loop by position
figure
for j=1:Nbr_Case % loop by case
plot(V_Time',M_Brut(:,i)) % plot Time Vs M_Brut (Data i line)
end
title(['Position N°: ' num2str(i) ' &' ' Case ' num2str(j)]) % title
legend(['Case' num2str(j)]) % legend
end

サインインしてコメントする。

その他の回答 (1 件)

Ced
Ced 2016 年 3 月 29 日
The matlab documentation is really good for that:
You need to:
a) open a new figure in each iteration of i
b) Keep the old lines as Azzi Abdelmalek pointed out.
for i=1:Nbr_Position % loop by position
%%OPEN NEW FIGURE WINDOW HERE
%%MAKE SURE OLD LINES ARE KEPT (see Azzi's answer)
for j=1:Nbr_Case % loop by case
plot(V_Time,M_Nett{i}(:,1:j)') % plot pair
% ...
end
end
I will let you fill in the blanks

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by