Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Please help me with this Error using * Inner matrix dimensions must agree.

조회 수: 1 (최근 30일)
Mikie
Mikie 2018년 1월 11일
마감: MATLAB Answer Bot 2021년 8월 20일
Can anyone correct this code for me? I don't know why I can't plot it.
mu = 0;
sigma = 1;
n = 10;
W = [0.7127 1.0967 0.4012 0.4379 0.2768 -0.2534 0.2828 0.2545 1.0773 -0.1154]
lambda = -2:0.5:2;
L(lambda) = n*log(2/sigma) + sum(log(normpdf((W-mu)/sigma))) + sum(log(normcdf((lambda*(W-mu)/sigma)))) - 3*pi^2*log(1+8*lambda^2/pi)/32
plot(lambda,L)
Thank you so much.
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 1월 11일
Your lambda is 9 elements long and your W is 10 elements long. What size are you expecting lambda*(W-mu)/sigma to be?

답변 (1개)

KSSV
KSSV 2018년 1월 12일
mu = 0;
sigma = 1;
n = 10;
W = [0.7127 1.0967 0.4012 0.4379 0.2768 -0.2534 0.2828 0.2545 1.0773 -0.1154] ;
% lambda = -2:0.5:2;
lambda = linspace(-2,2,length(W)) ;
L = n*log(2/sigma) + sum(log(normpdf((W-mu)/sigma))) + sum(log(normcdf((lambda.*(W-mu)/sigma)))) - 3*pi^2*log(1+8*lambda.^2/pi)/32 ;
plot(lambda,L)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by