"Matrix dimensions must agree"
Afficher commentaires plus anciens
Am trying to do some calculation between two matrix. unfortunately i keep getting this error. Other methods that i have tried such as bsxfun(@times run my computer into space. Any help given will be much appreciated. Here is the line of code
val = load ('edata.txt');
for data=2:1:length(val)-1
if(val(data) > val(data-1) & val(data) > val(data+1) & val(data) > 4)
val1(data) = 1;
else
val1(data) = 0;
end
end
figure
plot((val-min(val))/(max(val)-min(val)), '-g'); title('\bf Prominent Detection Peaks');
hold on
stem(val1'.*((val-min(val))/(max(val)-min(val)))', ':k');
hold off
The of dimension of val1 = 1x7167 and val contain 7168x1 Thanks in advance
6 commentaires
Stephen23
le 27 Jan 2018
"The of dimension of val1 = 1x7167 and val contain 7168x1"
What do you expect element 7168 of val to get multiplied with?
Evans Gyan
le 27 Jan 2018
Guillaume
le 27 Jan 2018
- Which line is giving the error, the stem line? Please give us the full error message.
- Which version of matlab?
- Why all the tranpose in stem(val1' .* expr') ?
- Is the intent of the above to obtain a 7167x7168 matrix, or a vector of 7167 or 7168 length?
- If the latter, then you haven't answered Stephen's question.
Evans Gyan
le 27 Jan 2018
Modifié(e) : Walter Roberson
le 28 Jan 2018
"The intent is [repeat of code that is in the question]"
There's absolutely no point in restating (for the 2nd time) the code that is in the question. We understand the code just fine. It can't work since the matrix dimensions don't agree.
We'd be a lot further if you answered the question we asked. So I repeat:
Is the intent to obtain a 7167x7168 matrix (which is what you'd use bsxfun for) or a vector of some length, possibly 7167 or 7168 (for which you'd never use bsxfun)?
If it's a vector, what do you expect element 7168 of val to get multiplied with?
Evans Gyan
le 28 Jan 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!