Effacer les filtres
Effacer les filtres

Regarding adding new axis to the array

47 vues (au cours des 30 derniers jours)
Aishwarya Venkatesh
Aishwarya Venkatesh le 1 Mai 2020
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.

Réponse acceptée

Kiran Felix Robert
Kiran Felix Robert le 5 Fév 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.
  1 commentaire
Aishwarya Venkatesh
Aishwarya Venkatesh le 7 Fév 2021
Thank you so much for your reply.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by