필터 지우기
필터 지우기

Sequencing, matrix values and calling function

조회 수: 1 (최근 30일)
Akmyrat
Akmyrat 2014년 7월 1일
댓글: Akmyrat 2014년 7월 2일
Lets say I have
A=[1 0 0;1 1 0;0 1 0], I=[1 0;0 1], F=[1 2;2 1]
matrix, and like this code:
for i=1:3
B=0;
for j=1:3
B=B+A(i,j)
end
if B==1;
R(i)= I
else B==2;
R(i)=F
end
end
..... this code is not working, but output should be like this
R1=[1 0;0 1], R2=[1 2;2 1], R3=[1 0;0 1].
Please can anyone help...

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 7월 1일
A=[1 0 0;1 1 0;0 1 0], I=[1 0;0 1], F=[1 2;2 1]
ii = sum(A,2);
z = {I,F};
out = z(ii);
  댓글 수: 2
Akmyrat
Akmyrat 2014년 7월 2일
sps Andrei...it gives me like this output, it is not what I want: out = [2x2 double] [2x2 double] [2x2 double]
Akmyrat
Akmyrat 2014년 7월 2일
Can you show me other ways please...

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

추가 답변 (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