필터 지우기
필터 지우기

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 CenterFile Exchange에서 Surface 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