Index exceeds matrix dimensions

Fomatted Code
clear, close all,
% wt and m work vectors:
wtv = load('hist-holo.dat');
mv = load('hist-zndpl.dat');
plot(1:length(wtv),wtv,'-s'), hold on
plot(1:length(wtv),mv,'-rs'), hold off
wtmv = [wtv mv];
wtm_sortedv = zeros(size(wtmv));
for i=1:size(wtmv,1)
[b1, ix1] = min(wtmv); % gives the candidate rows to take out
[bb, mincolumn] = min(b1); % gives the column to sort by
minrow = ix1(mincolumn); % min row
wtm_sortedv(i,:) = wtmv(minrow,:); % the ith row of the sorted matrix
wtmv(minrow,:) = []; % remove the min row, get new matrix
end
disp(wtm_sortedv), % the first column is wt, 2nd column is mut
figure,
plot(1:length(wtv),wtm_sortedv(:,1),'-s'), hold on,
plot(1:length(wtv),wtm_sortedv(:,2),'-rs'),
dW1 = wtm_sortedv(:,1) - wtm_sortedv(:,2);
ptab = zeros(size(dW1),1);
for i=1:size(dW1)
[h,p,ci] = ztest(dW1(1:i),0,4);
ptab(i) = p;
end
figure,
semilogy(ptab,'s-'), hold on
semilogy([1:length(dW1)],repmat(0.05,[1 length(dW1)]),'--r')
ylim([10^-6 1])
xlabel 'Number of Data Points'
ylabel 'Statistical significance(semilog scale)'
Example of wtv :
66.3211
68.8575
66.1813
108.414
89.9726
91.535004
78.2409
58.82
62.3149
42.9049
66.384995
77.3345
67.115005
94.4117
83.4924
63.3274
57.0875
85.035004
88.6679
79.5006
92.9922
80.5643
125.06
72.8234
73.1896
72.1010
87.99
98.4403
61.7436
97.8261
65.3285
73.5069
69.294998
66.2401
81.1372
81.6724
113.67
64.1265
87.9247
79.4155
62.5266
99.751
147.353
72.8242
80.5327
68.1298
76.675003
69.0567
Examle of mv:
62.2212
75.1972
56.701
74.5469
72.8212
74.54
64.5433
47.89
64.0485
89.4861
60.56
71.7556
52.4
57.4898
64.456
75.7041
75.5621
67.09
109.289
52.1048
111.949
57.6765
100.89
72.116
57.6215
79.3462
67.2267
94.3336
111.799
70.865
97.6164
60.0634
57.89
105.257
89.1614
56.6178
98.93
80.1458
65.4469
55.89
83.6092
84.135
76.3865
51.78
59.3375
63.3631
54.79
62.1234

3 comentarios

Paulo Silva
Paulo Silva el 14 de Jul. de 2011
please format the code
{code}
the cyclist
the cyclist el 14 de Jul. de 2011
Also, rather than making us load data that we don't have, can you provide an example of "wtv" and "mv" that doesn't work?
Atanu
Atanu el 14 de Jul. de 2011
I have now given the formatted code along with examples of wtv and mv that does not work.
Thanks

Respuestas (1)

Sean de Wolski
Sean de Wolski el 14 de Jul. de 2011
dbstop if error
size(wtm_sortedv(i,:))
size(wtmc(minrow,:))
should tell you what the size discrepancy is.

La pregunta está cerrada.

Preguntada:

el 14 de Jul. de 2011

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by