フィルターのクリア

I have a cell array and want to plot each of the cells on a tiled layout.

22 ビュー (過去 30 日間)
k
k 2020 年 7 月 17 日
回答済み: Anmol Dhiman 2020 年 7 月 20 日
I have a cell array which contains nx2 matricies in each cell. I'm trying to figure out how to plot each of those cells (x vs y) in a loop. Any ideas?
This is what I have:
numColmns = size(Data, 2);
for i = 1:2:numCols-1
A{i} = Data(:, i:i+1);
end
B = A(:, 1:2:end); %removes empty cells in cell array A
numPlots = length(B); %number of plots to make
tiledlayout(numPlots,1) %total number of plots in a row by 1 column
%insert loop where it automatically plots all cells in B
B gives me B{1}, B{2}, ... , B{n}, etc.
  2 件のコメント
Image Analyst
Image Analyst 2020 年 7 月 17 日
So "A" is your cell array, but what is Data? Give an example of Data, either in a .mat file or with code to generate it.
And what is tiledlayout()? Is that a function you're supposed to build that uses plot()? How many plots do you want? Each curve in a separate plot (using the subplot() function), or all curves on the same plot?
Fangjun Jiang
Fangjun Jiang 2020 年 7 月 17 日
Note A{2}, A{4},... are empty

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

採用された回答

Anmol Dhiman
Anmol Dhiman 2020 年 7 月 20 日
Hi Khiana,
You can use the below code
A_new ={}; % Cell array declared as A in your code
numColmns = size(A, 2);
for i = 1:2:numColmns-1
A_new{i} = A(:, i:i+1);
end
B = A_new(:, 1:2:end); %removes empty cells in cell array A
numPlots = length(B); %number of plots to make
tiledlayout(numPlots,1) %total number of plots in a row by 1 column
for i = 1: numPlots
a = B{i}';
nexttile
plot(a(1,:),a(2,:))
end
Regards,
Anmol Dhiman

その他の回答 (0 件)

カテゴリ

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