How to fix the error "Matrix dimensions must agree" in my code

조회 수: 1 (최근 30일)
may
may 2013년 9월 22일
I have the following two functions:
function [answer]=Sum_of_randomVariable(mean11,sigma11,mean12,sigma12,mean21,sigma21,mean22,sigma22,z)
A=@(x)FindIntegral(mean11,sigma11,mean12,sigma12,x);
B=@(x)FindIntegral(mean21,sigma21,mean22,sigma22,x);
F=@(y)A(z-y).*B(y);
answer= integral(F,-Inf,Inf);
end
function [answer] = FindIntegral(mean1,sigma1,mean2,sigma2,u)
F = @(x)normpdf(x, mean1, sigma1).*normpdf(u./x, mean2, sigma2).*(1./abs(x));
answer= integral(F,-Inf,Inf);
end
When I run Sum_of_randomVariable for the following input parameters:
Sum_of_randomVariable(1,0.2,2,0.5,5,0.6,2,5,2)
I get the following error: Error using ./ Matrix dimensions must agree.
I would appreciate if you could help me fix this error. Thank you.

답변 (1개)

Image Analyst
Image Analyst 2013년 9월 22일
Evidently x and u aren't the same size. Set a breakpoint there. What does it say their sizes are?
  댓글 수: 1
may
may 2013년 9월 22일
I set a breakpoint, the size of u is 1*150 double, but I cannot see the size of x.

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

카테고리

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