Matrix must be square
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function Proses_CC_Callback(hObject, eventdata, handles)
% hObject handle to Proses_CC (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load data_x x;
load data_i i;
load data_p p;
load data_l l;
xbar=mean(x);
ibar=mean(i);
pbar=mean(p);
lbar=mean(l);
C1=sum(x-xbar)*(i-ibar)/(sum((x-xbar)^2)*sum(i-ibar)^2)^1.5;
C2=sum(x-xbar)*(p-pbar)/(sum((x-xbar)^2)*sum(p-pbar)^2)^1.5;
C3=sum(x-xbar)*(l-lbar)/(sum((x-xbar)^2)*sum(l-lbar)^2)^1.5;
%C1=(sum((x-xbar)*(i-ibar)))/((sum(x-xbar)^2)*(sum(i-ibar)^2)^1.5);
%C2=(sum((x-xbar)*(p-pbar)))/((sum(x-xbar)^2)*(sum(p-pbar)^2)^1.5);
%C3=(sum((x-xbar)*(l-lbar)))/((sum(x-xbar)^2)*(sum(l-lbar)^2)^1.5);
minimum = min([C1 C2 C3]);
if (C1 == minimum)
class = 'temuireng'
else if (C2 == minimum)
class = 'temuputih'
else (C3 == minimum)
class = 'temulawak'
end
set(handles.minimum, 'string',[ 'rimpang:' , num2str(class)]);
end
can help me? in the command window appears:
??? Error using ==> mpower
Matrix must be square.
Error in ==>
One_Minus_CC_new>Proses_CC_Callback at 267
C1=sum(x-xbar)*(i-ibar)/(sum((x-xbar)^2)*sum(i-ibar)^2)^1.5;
0 commentaires
Réponse acceptée
Matt Fig
le 23 Oct 2012
Modifié(e) : Matt Fig
le 23 Oct 2012
Did you mean to take the element-by-element power of the arrays? Look at the difference:
x = magic(2) % A 2-by-2 matrix, for example.
x^2 % No dot, equivalent to x*x, need to have square matrix.
x.^2 % Note the dot (.) Need not be a square matrix.
So in your code you use (^2) instead of (.^2), is that what you meant to do?
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!