numerical integration dimension error

조회 수: 1 (최근 30일)
john birt
john birt 2011년 3월 2일
ok now Im getting another type of error
X = 0:1:100; Y = X.^(-1/2)*exp(-0.5*(0.00009996^2/X+34.3713^2*X)); Z =trapz(X,Y)
??? Error using ==> mldivide
Matrix dimensions must agree.
Whats wrong here? and how can I numerically integrate Y?

채택된 답변

Matt Fig
Matt Fig 2011년 3월 2일
You need a dot before every ^, * and / when working with vectors.
Y = X.^(-1/2).*exp(-0.5*(0.00009996^2./X+34.3713^2*X));
  댓글 수: 3
Matt Fig
Matt Fig 2011년 3월 2일
You may not be expecting NAN, but that is how to make Y from X. Look at the exponent, it has values from -590 to -Inf. What do you think e^-590 is? ZERO (for all intents and purposes).
john birt
john birt 2011년 3월 2일
Thanks for your wisdom, I can get an answer if I change it to something like
X = 0.001:0.001:0.003; Y = X.^(-1/2).*exp(-0.5*(0.00009996^2./X+34.3713^2*X)); Z = trapz(X,Y)
Z = 0.0172
thanks again for your comments (dumb matlab coders like me need help!)

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

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