Regarding adding new axis to the array
23 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Kiran Felix Robert
2021-2-5
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!