Subscripted assignment dimension mismatch.

1 vue (au cours des 30 derniers jours)
Jonathan Wilson
Jonathan Wilson le 18 Juin 2013
% name: MaxEff.m function [MaxEff] = KTKQMaxEffoutput(OptEff)
MaxEff = zeros(size(OptEff, 2), size(OptEff, 3)); for im = 1:size(OptEff, 2) for iim = 1:size(OptEff, 3) MaxEff(im, iim) = findpeaks(OptEff(:, im,iim)); end end %MaxEffAVE = zeros(MaxEff, 1); %for ia = 1:size(MaxEff, 2) % MaxEffAVE(ia) = findpeaks(MaxEff(:, ia)); %end
end
that is my code and the OptEff is 17x10x11 and i want to get the peaks out!
Please help me.
  1 commentaire
Jan
Jan le 18 Juin 2013
Do you see that omitting the code formatting decreases the readability of your code?

Connectez-vous pour commenter.

Réponses (1)

random09983492
random09983492 le 18 Juin 2013
Hi Jonathan,
Your problem is that the findpeaks function can return an empty array, [ ], or an array with multiple entries [peak1, peak2, ..., peakN], neither of which can be assigned to a single array element.
My suggestion would be to make your MaxEff variable a cell rather than an array. Declare MaxEff like this:
MaxEff = cell(size(OptEff, 2), size(OptEff, 3));
and access it like this:
MaxEff{im, iim} = findpeaks(OptEff(:, im,iim));
Hope that helps,
Elliot
  1 commentaire
Jonathan Wilson
Jonathan Wilson le 19 Juin 2013
That is a great answer :) sorted!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by