could anyone help me to solve my question

jaah navi

jaah navi (view profile)

님이 질문을 제출함. 12 May 2019
최근 활동 gonzalo Mier

gonzalo Mier (view profile)

님이 댓글을 추가함. 13 May 2019
As i am unable to get the answer i am asking it again.
I am having two matrices A=[0.6399 0.8965] and B=[ 0.7684 0.0120;
0.5333 0.9666;
0.0684 0.8322;
0.1996 0.4453]
of different sizes generated in my code.
when size(A) is lesser than size(B) i done with the following command line
code1:
[jj,kk]=size(A)
[jjj,kkk]=size(B)
zz=zeros(jjj,kkk)
zz(1:jj,1:kk)=A
C=B-zz
the code executes and gives me the result.
As A and B are generated by the code,sometimes size(A) is greater than size(B) so i have used the following command line
code2:
A=A(size(B,1),:)
social=B-A
the code executes and gives me the result.
As i doesnt know whether size(A) is greater or lesser than size(B) i need to use the above code 1 and code 2 together by using if condition.
Could anyone help me how to use if condition with respect to code 1 and code 2.

로그인 to comment.

답변 수: 1

gonzalo Mier

gonzalo Mier (view profile)

님의 답변 12 May 2019

You don't need if here. You can mix them as:
C = B;
len_A = min(size(B,1),size(A,1));
C(1:len_A,:) = C(1:len_A,:) - A(1:len_A,:);

gonzalo Mier

gonzalo Mier (view profile)

13 May 2019
If this answer helps you, please accept it :)

로그인 to comment.