Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Error in plot code
조회 수: 3 (최근 30일)
이전 댓글 표시
The code is very simple where I have to plot the denoising error as a function of mu. how ever I am getting error at
err(i) = abs(a1);
with the message : In an assignment A(I) = B, the number of elements in B and I must be the same. I see absolutely nothing that could logically go wrong but still, what's wrong?
mulist = linspace(.1,3.5,31);
err = zeros(1,length(mulist));
for i = 1:length(mulist)
a1=x-x0;
err(i) = abs(a1);
end
figure;
plot(mulist,err, '.-'); axis('tight');
set_label('\mu', 'SNR');
댓글 수: 0
답변 (1개)
Walter Roberson
2014년 2월 15일
You have not show us x or x0. One or both of them are vectors (or arrays), and you are trying to store abs() of the vector arithmetic inside the single element err(i) .
Notice that your "for i" loop goes to length of mulist but "a1=x-x0" does not depend upon mulist at all, so each a1 value would be exactly the same.
댓글 수: 2
Walter Roberson
2014년 2월 15일
snr() takes in a vector and returns a single value, the signal to noise ratio.
minus of two vectors returns another vector the length of the originals.
[9, 5, 2] - [4, 11, 21] = [5, -6, -19]
Are you trying to find the "distance" between the two vectors? If so then minus is not the right operation for that. For that you would want something like the Euclidean Distance,
sqrt(sum((x-x0).^2))
Perhaps, though, you are trying to find the correlation of the two vectors. Or perhaps you are trying to find the lag between them. Or perhaps you are trying to find a measure of whether they are considered to be drawn from the same distribution. Or... lots of things you might have intended. What were you thinking that minus would do for you?
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!