Regarding adding new axis to the array
조회 수: 18 (최근 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!