필터 지우기
필터 지우기

integrate 3 matrix into one matrix

조회 수: 1 (최근 30일)
fatema saba
fatema saba 2014년 12월 22일
댓글: fatema saba 2014년 12월 22일
Hello
I have a problem.
I have 3 matrices (q,e and w) like that:
q=[1:4]
e=q'
and
w=zeros(3,3)
I want to create matrix A by integrating matrix q, e and w
matrix A must be something like that:
A=[1 2 3 4;
2 0 0 0;
3 0 0 0;
4 0 0 0]
I write something but It doesn't work correctly
my code is:
function [ A ] = gams1(q,e,m,n)
q=[1:4]
e=q'
w=zeros(3,3)
m=4
n=4
A=zeros(m,n)
for i=1:m*n
if i==i>=1 && i<=n
iA=q
continue
elseif rem(i,n)==1
iA=e
end
end
[A]

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 12월 22일
편집: Andrei Bobrov 2014년 12월 22일
A = [e,[q(2:end);w]];
OR
A = hankel(q);
A(2:end,2:end) = 0;
  댓글 수: 1
fatema saba
fatema saba 2014년 12월 22일
Thank you for your answer.
It is excellent but is there any way to correct my answer (I mean is my code correctable?)
Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by