Error clicking the GUI interface button in matlab

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-0.
Error in matriz_destino (line 10)
mat(2,1) = double(char(get(findobj(gcf,'Tag','p14'),'String')));
Error while evaluating UIControl Callback.
---------------------------
Incapaz de realizar a atribuição porque o tamanho do lado esquerdo é 1 por 1 e o tamanho do lado direito é 1 por 0.
Erro em matriz_destino (linha 10)
mat (2,1) = double (char (get (findobj (gcf, 'Tag', 'p14'), 'String')));
Erro ao avaliar o retorno de chamada UIControl.

2 Comments

Part of code:
mat = zeros(5,5); % matriz de zeros 5x5.
mat(5,1) = double(char(get(findobj(gcf,'Tag','p11'),'String')));
mat(4,1) = double(char(get(findobj(gcf,'Tag','p12'),'String')));
mat(3,1) = double(char(get(findobj(gcf,'Tag','p13'),'String')));
mat(2,1) = double(char(get(findobj(gcf,'Tag','p14'),'String')));
mat(1,1) = double(char(get(findobj(gcf,'Tag','p15'),'String')));
"the size of the right side is 1-by-0"
"o tamanho do lado direito é 1 por 0"
The result on the right side of the equal sign is empty.
This could be because findobj(gcf,'Tag','p11') is not finding any objects:
findobj(gcf,'Tag','p11')
ans =
0×0 empty GraphicsPlaceholder array.
double(char(get([],'String')))
ans =
[]
But even if it did find the correct object, it doesn't look like you're converting the string correctly. After you figure out the correct findobj() inputs, assuming the string is a number, try,
h = findobj(____);
mat(5,1) = str2double(get(h,'string'));
% or
mat(5,1) = str2double(h.String);

Sign in to comment.

Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Asked:

on 28 Aug 2020

Edited:

on 28 Aug 2020

Community Treasure Hunt

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

Start Hunting!