Time Vector in X axis Plotting

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 !!

 采纳的回答

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
You're welcome!

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Logical 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by