create 3-dimension matrix
이전 댓글 표시
Hi
A Question please.
I want to write a function that create a 3-dimension matrix based on two 2-demnesion matrices.
I named this new matrix C.
I write something but when I run it give me "ans" but I want to give me matrix C.
this is my simple code
function Model=Base()
load('test1.mat');
%z1=[90 50 159;148 120 31;142 3 74];
%z2=[13 155 108;141 40 102;109 119 144];
[m,n]=size(z1);
for k=1
c(:,:,k)=z1;
end
for k=2
c(:,:,k)=z2;
end
Model.c=c
end
What is rong in my code please?
Thank you
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2015년 1월 1일
c=cat(3,z1,z2)
댓글 수: 5
fatema saba
2015년 1월 1일
Azzi Abdelmalek
2015년 1월 1일
It's not C but c. Just type
c
you will see the result
fatema saba
2015년 1월 1일
Azzi Abdelmalek
2015년 1월 1일
But your function return just the variable model , in this case just type
Model
fatema saba
2015년 1월 1일
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!