how to plot different cell arrays in just one graphic?

Probably it could be a tricky question... however : having 2 different cell arrays, how can I plot the first cell (of the first array) and then the first cell (of the second array) consecutively and create a general plot in the same way for the other cells? , all together in a plot. Thanks.

 채택된 답변

Walter Roberson
Walter Roberson 2021년 6월 22일
temp = [reshape(First, 1, []);
reshape(Second, 1,[])];
plot(temp{:})

댓글 수: 5

Fercho_Sala
Fercho_Sala 2021년 6월 23일
편집: Fercho_Sala 2021년 6월 23일
@Walter RobersonI just got the error : 'Brace indexing is not supported for variables of this type.' data attached.
Your posted question says you have two cell arrays, but the data you posted has two numeric arrays, one 1 x 24 and the other 1 x 12.
I do not know what it means to plot one "cell" of a numeric array. Interleave maybe?
SS = [reshape([S(1:12); S7],1,[]),S(13:end)]
S7 has a number of nan values, so the resulting plot is disconnected.
Fercho_Sala
Fercho_Sala 2021년 6월 24일
편집: Fercho_Sala 2021년 6월 24일
@Walter Roberson yes, interleave is the right word and the way you wrote the code it works perfectly, the first example for cell arrays and the second one for numeric arrays, however it doesn’t have always the same numbers (the size of S and S7), in your example ‘12’ and ‘13’ I was wondering how can I do it in a general way independently of those number? Thanks.
maxinter = min(length(S), length(S7));
SS = [reshape([S(1:maxinter); S7(1:maxinter)], 1, []), S(maxinter+1:end), S7(maxinter+1:end)];
This code is valid no matter whether S or S7 is the longer vector, as long as both of them are row vectors.
@Walter Roberson yes, it works perfectly, thank's a lot for your knowledge :)

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

추가 답변 (0개)

카테고리

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

제품

릴리스

R2020b

질문:

2021년 6월 22일

댓글:

2021년 6월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by