Equivalent of deal for a table
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
I often use deal to change the values of several cells in a cell array of strings:
a = 1:5;
b = {'one', 'two', 'three', 'four', 'five'};
[b{a>3}] = deal('big');
However, I just discovered that attempting the same operation on a table variable throws an error:
a = 1:5;
b = {'one', 'two', 'three', 'four', 'five'};
t = table(a,b);
[t.b{t.a>3}] = deal('big');
yields:
Expected one output from a curly brace or dot indexing expression, but there were 2
results.
Is there an equivalent syntax to quickly reassign values in a table?
3 Kommentare
  Cedric
      
      
 am 29 Jul. 2015
				Hmm, not as bad as a rainbow color map ;-) but still.. well, hopefully this will become a built-in in a near future! (not 2015b though, because I have the same issue on the pre-release)
Antworten (1)
  Bernard
      
 am 7 Feb. 2021
        It would be nice to have this functionality.  In the meantime, this works, although not as elegant.
t.b(t.a>3) = repmat({'big'}, size(t.b(t.a>3)))
0 Kommentare
Siehe auch
Kategorien
				Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

