登录论坛

查看完整版本 : 【求助】大家帮忙看看这段代码有什么问题啊?


Ayu
2008-03-10, 09:13
M=load('hemo.mat')
P= M.hemo

HR= find(P(:,24)>=15);
NHR= find(P(:,24)<15);
A= P(HR,1);
B= P(NHR,1);
X= size(A)
Y= size(B)

F1=0;
for i=1:71
P= M.hemo
P(i,:)=[];
HR1= find(P(:,24)>=15);
NHR1= find(P(:,24)<15);
A= P(HR1,1);
B= P(NHR1,1);
[rf,rxi]= ksdensity(A)
[nrf, nrxi]= ksdensity(B)

S1= sign(rf(7)-nrf(7)); % assign x axis from 1 to 100, and we start to look for threshold from the 7th value. Because the first ones are both 0, that’s not what we want.
for j = 1:100
S2=sign(rf(j)-nrf(j));
if S1~=S2
disp(j); % the index of the threshold
break;
end
end
threshold=nrf(j)

U=P(i,1)
if U>threshold
RP= 1;
F1=F1+1;
else
RP=0;
end

disp('F1=');
disp(F1)

end

其中M是一个72×24的矩阵。
为什么每次运行后会显示
??? Error using ==> mrdivide
Matrix dimensions must agree.
的错误信息呢?

哪位高手帮忙啊!

dnping
2008-03-10, 09:26
建议楼主看一下matlab函数的help,在矩阵之间运算的时候需要考虑矩阵的维数问题,如果两个或者多个矩阵里面有一个矩阵维数不满足运算要求的话,就会提示这个问题,楼主好好检查一下程序……