MATLAB Answers

How can i extract Index values of different cell arrays

40 views (last 30 days)
Ram on 29 Jul 2018
Commented: Ram on 30 Jul 2018
I want to extract the cell arrays the index num,
for w =1:length(mydata)
%[~,I]= find(mydata{w, 2}(:,2)) = find(mydata{w, 1}(:,1));
for o = 1:length(mydata{w,2})
index = find(mydata{w, 2}(:,2) == mydata{w, 1}(:,1)== o);
mydata{w,3} = index;
I have a cell which contains max and its index values in each row. Now i want to find max index values in another cell and extract those values( matrix 1*2, here i want to extract only 1st col value only). for ex. [M,I] = [2,295]. 295 index value of its max value in certain row, let say (6,26321) is the extracted index value in another cell. extract value is 6(1st col) similarly all other row cells matrix. Thanks in advance.
Ram on 30 Jul 2018
@image analyst thanks for your support. above code writtens only my max and index values again, But this is not my required output. here input matrix is 1*2 which has [max ind] values. but we consider only index values in order to find index values in 999*2 matrix. as i said in above. And here other cell/rows cells means to find all index values for each cell (999*2) array from the 1*2 matrix. sorry for inconvienence about explanation.

Sign in to comment.

Accepted Answer

jonas on 30 Jul 2018
Edited: jonas on 30 Jul 2018
Something like this should work.
s = load('mydata21.mat')
c=s(:,2) %arrays with indices
d=s(:,1) %arrays with values
Ram on 30 Jul 2018
@jonas Thanks alot. You are just genius and saved my time.

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!