フィルターのクリア

Using Function to plot matrices with changing inputs

2 ビュー (過去 30 日間)
Philip Hoskinson
Philip Hoskinson 2016 年 3 月 3 日
コメント済み: Jan 2016 年 3 月 5 日
I would like to send a cell into a function, and have each matrix plotted from the cell. How can I input legend based on changing inputs?
Example:
function [ ] = AVG_Plot_Function(X,Degrees,Data )
for k = 1:size(Data)
AVG{k} = mean(Data{k},1)
a{k} = polyfit(X,AVG{k},3)
b{k} = polyval(a{k},X)
plot(X,AVG{k},X,b{k})
legend(Degrees(k)...) ..> this only puts the last entry, need all the labels.
hold on
end
end

回答 (1 件)

Jan
Jan 2016 年 3 月 3 日
編集済み: Jan 2016 年 3 月 5 日
axes('NextPlot', 'add'); % as "hold on"
LineHC = cell(1, numel(Data)); % [EDITED]
for k = 1:numel(Data) % Not SIZE!
AVG{k} = mean(Data{k},1)
a{k} = polyfit(X,AVG{k},3)
b{k} = polyval(a{k},X)
LineHC{k} = plot(X,AVG{k},X,b{k}); % [EDITED]
end
LineH = cat(1, LineHC{:}); % [EDITED]
legend(LineH, Degrees);
  2 件のコメント
Philip Hoskinson
Philip Hoskinson 2016 年 3 月 3 日
編集済み: Philip Hoskinson 2016 年 3 月 3 日
Subscripted assignment dimension mismatch.
Error in AVG_Plot_Function (line 11) lineH(k) = plot(X,AVG_Cavity{k},X,b{k},'--k')
--> Stops after one iteration:issue plotting that data and the fit lines perhaps?
Jan
Jan 2016 年 3 月 5 日
See [EDITED]: PLOT draws 2 lines and replies 2 handles, which could not be stored in the scalar LineH(k).

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

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by