What should be a very simple bit of code is causing me lot's of trouble, X = find(I0_data == I0_unique(i,1));

I believe that the code is correct as it has worked for me on many occasions, but I am having trouble with this data set and for the life of me I cannot work out why.
I've attached the data set and the matlab .m file in a zip file.
I understand the error that has been generated. The code is stopping short because the index is out of bounds, the Index is generated by matlab and should never become out of bounds.
Please could someone take a look at it if they get a chance.
Thanks in advance, Matt
The error: ??? Attempted to access I0_data(31137,2); index out of bounds because size(I0_data)=[31136,12].
Error in ==> Weibull_output at 10 Y (u,1) = I0_data (u,2) - I0_data (X(1,1),2);

2 件のコメント

Jan
Jan 2011 年 6 月 13 日
Please take the time to isolate the relevant part of the code and post it directly. I will not download a zip file.
Matt
Matt 2011 年 6 月 13 日
Sorry about that, I've added the code and a link to the .txt file
Thanks,
Matt

サインインしてコメントする。

 採用された回答

Matt
Matt 2011 年 6 月 13 日

0 投票

X = find(I0_data (:,1) == I0_unique(i,1));

その他の回答 (2 件)

Matt
Matt 2011 年 6 月 13 日
here is the full code:
I0_unique = unique(I0_data (1:31136))';
[a,b] = size(I0_unique);
for i = 1:a;
X = find(I0_data == I0_unique(i,1));
for u = X(1,1):X(end) Y (u,1) = I0_data (u,2) - I0_data (X(1,1),2);
u;
end
e = X(end); s = X(1:1); y = I0_data(s:e,3); x = Y(s:e,1);
Out(i,1:2) = polyfit (x,y,1);
i; end
I think the problem is here:
X = find(I0_data == I0_unique(i,1));
But tbh I think it may be the data set causing the problem.
here is the .txt file with the data set in:
Thanks in advance, Matt
Matt
Matt 2011 年 6 月 13 日

0 投票

Right I think I have had a little breakthrough.
The problem is here:
X = find(I0_data == I0_unique(i,1));
Specifically "I0_data"
I haven't told Matlab which column to look into. I would like Matlab to search the whole of column 1 so I presume I need another loop?

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

質問済み:

2011 年 6 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by