Filter löschen
Filter löschen

Get result from uitable's row number

1 Ansicht (letzte 30 Tage)
Light
Light am 8 Jun. 2013
I have uitable below and i wanna get results uitable's row number not matrix's row number.
f = figure('Position',[10 10 600 600]);
dat = {-1,1,1;0,-1,0;0,0,-1;1,0,0};
cnames = {'12','23','25'};
rnames = {'11','12','23','14'};
t = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
'RowName',rnames,'Position',[10 10 590 590]);
blnA = logical( A == -1 );
blnOut = find(any(A == -1,2));
max(blnOut)
ans =
3
My expected result is 23 not 3. How can i get that value?
  2 Kommentare
Walter Roberson
Walter Roberson am 8 Jun. 2013
You have not defined "A"
Light
Light am 8 Jun. 2013
A=[-1,1,1;0,-1,0;0,0,-1;1,0,0];
I confused i think my workspace kept that A matrix and result is 3.
Anyway, how can i get value 23. I will not use A matrix i will use it in uitable
dat = {-1,1,1;0,-1,0;0,0,-1;1,0,0};
What will i do?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 8 Jun. 2013
rnames are not a row number: rnames are row labels. You find the row number (a numeric value) but somehow you expect a string that is the row label to be returned by max() . max() never returns strings.
rnames{blnOut}
will give you the row label associated with the row #blnOut
  4 Kommentare
Light
Light am 8 Jun. 2013
I'm again
f = figure('Position',[10 10 600 600]);
dat = {-1,1,1;0,-1,0;0,0,-1;1,0,0};
cnames = {'1','2','5'};
rnames = {'1','2','3','4'};
t = uitable('Parent',f,'Data',dat,'ColumnName',cnames,... 'RowName',rnames,'Position',[10 10 590 590]);
blnA = logical( A == -1 );
blnOut = find(any(A == -1,2));
rnames{max(blnOut)};
negcolumn = find(A(min(blnOut),:) == 1);
cnames{max(negcolumn)};
dU(5)=7;
dU(cnames{max(negcolumn)})
Error message occurred. I couldn't find the mistake.(cnames{max(negcolumn)})=5 So it must be dU(5)=7 but error Index exceeds matrix dimensions.
Image Analyst
Image Analyst am 8 Jun. 2013

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by