Azzera filtri
Azzera filtri

My code is in drop box. it works on my laptop but doesn't work on PC

1 visualizzazione (ultimi 30 giorni)
Hello,
I have a code in drop box. It works on my laptop but doesn't work on PC (Shows Matrix Dimensions must agree). Could you guide me what the problem is? MATLAB version in my PC is 2016 and in my laptopa is 2016b.

Risposta accettata

Star Strider
Star Strider il 12 Apr 2017
My guess (since we don’t have your code) is that your code uses ‘implicit expansion’ that was introduced in R2016b. You need to replace the ‘implicit expansion’ calculations that are throwing the error with bsxfun calls. That way, they will be compatible with prior MATLAB versions.
  3 Commenti
Star Strider
Star Strider il 12 Apr 2017
My pleasure.
The repmat function is likely not causing the problem you are seeing.
The problem is most likely ‘implicit expansion’. In the Release Notes (link) for R2016b, see the section in Mathematics on:
  • Implicit Expansion: Apply element-wise operations and functions to arrays with automatic expansion of dimensions of length 1
See especially the Compatibility Considerations section. I cannot link directly to this part of the documentation, so you will have to scroll down and read about it.
If you replace the calculations where you use ‘implicit expansion’ with appropriate calls to bsxfun (link), your code will be compatible with both versions of MATLAB.
Walter Roberson
Walter Roberson il 12 Apr 2017
To make this more concrete:
You probably add a row vector to a column vector, which is something that is defined for R2016b or later but not in earlier code. Or possibly you add (or subtract) a vector with a matrix, such as if you had
A - mean(A)
For a 2D array, A, mean(A) would be a row vector, and a 2D vector minus a row vector is not defined before R2016b, and would have to be replaced with
bsxfun(@minus, A, mean(A))

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su EEG/MEG/ECoG in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by