Azzera filtri
Azzera filtri

Regarding adding new axis to the array

47 visualizzazioni (ultimi 30 giorni)
Hello,
I have (n*1) dimensional array, now i would like to add new axis to the array and would like to get (n*1*1) multidimensional array. I tried to do it based on the previous answers :
z2 = rand(500,1) ;
[inputStructOne(jz).cause_add_dim] = cat(3,inputStructOne(jz).cause, z2);
Howver, i am getting the answer as (500*1*2), i believe that it is trying to combine two variables but instead i want (500*1*1). In python the command is np.new axis, is there anything similar to that in matlab?
Any help will be highly appreciated.
Thanks a lot in advance.

Risposta accettata

Kiran Felix Robert
Kiran Felix Robert il 5 Feb 2021
Hi Aishwarya,
In MATLAB, a 1-D vector is a Nx1 vector similarly, any MxN vector, by-itself is a MxNx1 vector.
So the ‘cat’ command adds another layer to the existing MxNX1 vector in the third dimension which makes it a MxNx2 vector.

Più risposte (0)

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by