Disagreement of Matrix dimension
이전 댓글 표시
Hello Friends,
I have executed the following codes:
X=[8.3 13.9 12.5 22.2 8.3 11.1 18.1 11.1 6.9 6.9 6.9 19.4 9.7 4.2 5.6 12.5 11.1 6.9 8.3 8.3 13.9 9.7 6.9 6.9 8.3 5.6 12.5 4.2 18.1 11.1 4.2 8.3 12.5 15.3 5.6 6.9 13.9 13.9 18.1 12.5 15.3 29.2 36.1 30.6 22.2 40.3 41.7 52.8 50 52.8 61.1 55.6 72.2 69.4 68.1 68.1 76.4 94.4 77.8 101.4 81.9 73.6 93.1 76.4 48.6 52.8 41.7 44.4 43.1 25 26.4 19.4 25 19.4 16.7 13.9 8.3 15.3 5.6 5.6 5.6 5.6 9.7 6.9 2.8 8.3 9.7 8.3 11.1 12.5 15.3 8.3 13.9 4.2 16.7 5.6 8.3 16.7 4.2 11.1 2.8 8.3 5.6 8.3 4.2 11.1 12.5 8.3 8.3 9.7 13.9 15.3 19.4 20.8 25 23.6 25 25 25 33.3 26.4 23.6 27.8 19.4 22.2 19.4 23.6 26.4 15.3 23.6 15.3 26.4 13.9 9.7 15.3 11.1 11.1 18.1 9.7 16.7 18.1 9.7 11.1 22.2 18.1 13.9 19.4 20.8 18.1 13.9 15.3 19.4 13.9 16.7 20.8 12.5 18.1 15.3 15.3 12.5 8.3 12.5 20.8 15.3 15.3 12.5 13.9 9.7 18.1 8.3 19.4 16.7 12.5 12.5 13.9 6.9 9.7 11.1 16.7 5.6 8.3 11.1 4.2 12.5 2.8 12.5 11.1 8.3 9.7 8.3 8.3 18.1 12.5 11.1 8.3 9.7 6.9 12.5 5.6 8.3 0];
M=2;
N = length( X );
Z = ones(N,M) * 1/M; % indicators vector
P = zeros(N,M); % probabilities vector for each sample and each model
t = ones(1,M) * 1/M; % distribution of the gaussian models in the samples
u = linspace(min(X),max(X),M); % mean vector
sig2 = ones(1,M) * var(X) / sqrt(M); % variance vector
C = 1/sqrt(2*pi); % just a constant
Ic = ones(N,1); % - enable a row replication by the * operator
Ir = ones(1,M); % - enable a column replication by the * operator
Q = zeros(N,M);
thresh = 1e-3;
step = N;
last_step = inf;
iter = 0;
min_iter = 10;
when I try to execute the following code,
P = C ./ (Ic*sqrt(sig2)) .* exp( -((X*Ir -Ic*u).^2)./(2*Ic*sig2));
am getting this error:
?? Error using ==> mtimes
Inner matrix dimensions must agree.
The problem I have identified with that code,in particular (X*Ir)is both are matrix but of different sizes, say X = 1R&201C and Ir=1R&1C.
How to handle these different size matrices?
Please help me out.
Also suggest me some alternate codes. Thanks.
kra/-
댓글 수: 2
Oleg Komarov
2011년 8월 4일
Please format the code with the {} button, will increase the chance of an prompt answer.
Anandh
2011년 8월 4일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!