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.

 Réponse acceptée

temp = [reshape(First, 1, []);
reshape(Second, 1,[])];
plot(temp{:})

5 commentaires

Fercho_Sala
Fercho_Sala le 23 Juin 2021
Modifié(e) : Fercho_Sala le 23 Juin 2021
@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 le 24 Juin 2021
Modifié(e) : Fercho_Sala le 24 Juin 2021
@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 :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Produits

Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by