0

I want to print a table via uitable, with the data for the table-entries stored in a matrix called plot. Every entry should be a string, consisting of 2 chars i.e. p0 or u1,... The matrix should be filled in two nested for-loops.

But whenever I want to store a string as an element. i.e. plot(i,j)='a1' i get the error

"??? Assignment has more non-singleton rhs dimensions than non-singleton subscripts" 

on the other hand, when i initialize a matrix completely at the beginning i.e.

plot=['aa' 'ab';'ba' 'bb'] 

it seems to work just fine.

I would be very thankful for any ideas concerning the problem. Would there be any way to solve the problem with a cell array?

Robert Seifert
  • 25,078
  • 11
  • 68
  • 113
user2212532
  • 23
  • 1
  • 4

1 Answers1

1

To store string, use a cell array. Also, don't call your matrix plot, that's the name of a built in function. For example:

plotData{1,2} = 'hello';
plotData{1,1} = 'hi';

To access an item in the cell array:

plotData{1,1}
ans = hi
Molly
  • 13,240
  • 4
  • 44
  • 45
  • Oh, thanks a lot! I thought, a Cell Array wouldn't work as 'Data' with an uitable, but it seems to works just fine :) – user2212532 Mar 26 '13 at 17:14