loops - Tag Names As Variables And Displaying It In Matlab GUI -
i’m building gui in matlab (my first one), have 160 static text boxes tag name “tag_matrix_1, tag_matrix_2, etc”. i’m trying build loop puts tag names in vector:
for = 1:160 tagnames(i) = ['tag_matrix_' num2str(i)]; end
but i’ll error: “in assignment a(i) = b, number of elements in b , must same.” why? , how fix it?
my second question displaying in loop. possible loop it, don’t have 160 lines of setting static text boxes? like:
for = 1:160 set(handles."how can implement tagnames(i) in there",'string',data2d(i,:); end
rather trying store tag names in array (this fail because different sizes), create struct fieldname tag name , value handle itself. can use dynamic field referencing this.
for k = 1:160 field = ['tag_matrix_', num2str(k)]; myhandles.(field) = findobj(gcf, 'tag', field); end
then in second loop (to fill in values), you'd access fields of struct.
for k = 1:160 set(myhandles.(['tag_matrix_', num2str(k)]), 'string', data2d(k,:)); end
do need store tag_names
that? can use findobj
find element given tag. allow replace second loop with.
for k = 1:160 set(findobj(gcf, 'tag', ['tag_matrix_', num2str(k)]), 'string', data2d(k,:)) end
Comments
Post a Comment