フィルターのクリア

Plot from cell array

4 ビュー (過去 30 日間)
Isai Fernandez
Isai Fernandez 2021 年 4 月 25 日
編集済み: Adam Danz 2021 年 4 月 27 日
I want to plot data from cell array. I tried many ways, and I can't get it. I used plot inside and outside the loop, also scatter and stackedplot.
clc; clear variables; close all;
% Pregunta 01
filename='Test_Specimen_2.txt';
D = readtable('Test_Specimen_2.txt',...
'Range','A10:AN76',...
'ReadVariableNames',true);
i=1;
while i<=size(D,2)/2
d1 = D(:,2*i);
d2 = D(:,2*i-1);
D1{i} = [d1 d2];
i=i+1;
end
i=1;
while i<= size(D1,2)
stackedplot(D1{i},{'STRAIN','STRESS'});
hold on
i=i+1;
end

回答 (1 件)

Adam Danz
Adam Danz 2021 年 4 月 25 日
編集済み: Adam Danz 2021 年 4 月 27 日
It looks like you're trying to create a stackedplot with 2 lines per axes which is demonstrated here:
Instead of grouping columns of data in cell arrays, you just need to group the variable names together. It appears you want the lines to be grouped as [Var2, Var1], [Var4, Var3], [Var6, Var5], etc. Here's how to achieve that with stackedplot.
D = array2table(rand(10,8)); % demo table
varPairs = [D.Properties.VariableNames(2:2:end)', ...
D.Properties.VariableNames(1:2:end)'];
pairedVars = arrayfun(@(r){varPairs{r,:}},1:size(varPairs,1),'UniformOutput',false)'; %#ok<CCAT1>
stackedplot(D,pairedVars)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by