First time matlab user problem Matrix dimensions must agree?
1 view (last 30 days)
I'm a first time matlab user and I've run into a bit of a problem I keep getting an error. Here is my sequence of codes:
Error using .*
Matrix dimensions must agree.
Error in applyfilter (line 3)
Here is the script "applyfilter":
Any help would be appreciated thanks.
Image Analyst on 23 Apr 2013
What does derivefilter() return? You're not accepting any matrix for the filter that you can then pass in to applyfilter() instead of ans. You may need to have something like
myFilter = derivefilter(FREQSPEC,600);
but we can't tell until we know what's inside derivefilter().
More Answers (2)
Leah on 23 Apr 2013
imgspec and filter must have the same dimension to do a element-wise multiplications
Jan on 23 Apr 2013
Edited: Jan on 23 Apr 2013
Your code would be easier to read, if you spend the time for reading the manuals for this forum and format the code properly.
It looks like:
imgspec .* filter
cannot work, because the array sizes do not match. This is surprising, because the value of filter seems to be a scalar.
Using ans explicitly is a bad idea, because this value is very volatile and debugging can change the value. filter is not a good choice also, because this is a name of an important built-in function.