aa = {rand(482,5) , rand(493,5)};
t = linspace(0, 20,975 ); % Generating Time Vector Series
Now how can I plot the cell data "aa" while keeping Time vector Series will lie in the X-axis?
Thanks in ADVANCE !!

 채택된 답변

Voss
Voss 2022년 6월 3일

0 개 추천

aa = {rand(482,5) , rand(493,5)};
t = linspace(0, 20,975 ); % Generating Time Vector Series
n_aa = cellfun(@(x)size(x,1),aa)
n_aa = 1×2
482 493
plot(t(1:n_aa(1)),aa{1})
hold on
plot(t(n_aa(1)+(1:n_aa(2))),aa{2})

댓글 수: 4

Thank you for the answer.
But what will happen if I have the cell array, aa ={ 3 or more cell }. Then How I shall plot?
plot(t(1:n_aa(1)),aa{1})
hold on
plot(t(n_aa(1)+(1:n_aa(2))),aa{2})
% this time, I'll start with n_aa
n_aa = randi([480 500],1,7)
n_aa = 1×7
481 488 490 489 500 489 497
% and generate random aa from n_aa
aa = arrayfun(@(x)rand(x,5),n_aa,'UniformOutput',false)
aa = 1×7 cell array
{481×5 double} {488×5 double} {490×5 double} {489×5 double} {500×5 double} {489×5 double} {497×5 double}
% t is defined as before (but with more elements)
t = linspace(0, 20, sum(n_aa));
% generate t_idx to help with plotting
t_idx = cumsum([0 n_aa])
t_idx = 1×8
0 481 969 1459 1948 2448 2937 3434
% plot in a loop this time
hold on
for ii = 1:numel(aa)
plot(t(t_idx(ii)+1:t_idx(ii+1)),aa{ii})
end
Amit Chakraborty
Amit Chakraborty 2022년 6월 3일
Thank you very much !
Voss
Voss 2022년 6월 3일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

질문:

2022년 6월 3일

댓글:

2022년 6월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by