dynamic title in app.UIAxes won't work

13 visualizaciones (últimos 30 días)
Raymond Gilbers
Raymond Gilbers el 2 de Jun. de 2021
Comentada: Raymond Gilbers el 3 de Jun. de 2021
Good evening,
Apearantly im doing something completely worng therefore the next question. I have a UIAxes on my canvas and want to make the title dynamic. So the name of the title will change according certain radioboxes I have. I created a function but when the function gets called and prepare the string then the title will be set and I get an error.
%This part happens in the plot function which was working until I tried to
%fix the title, in properties header is defined
app.strOpt = 'Cumulative';
app.strData = 'Cases';
header = app.PlotTitles();
title(app.UIAxes, header );
Than I have a function as below:
function Out = PlotTitles(app)
str = strcat({app.strData}, {' of COVID-19 '}, {app.strOpt});
disp(str)
select = app.CountryListBox.Value;
t = strcmp(select, 'Global');
if t == 0
Out = strcat({str}, {' in '},{app.CountryListBox.Value});
disp(Out)
else
Out = strcat({'Global '}, {str});
disp(Out)
end
end
I get an error that tells me that:
Error using matlab.graphics.primitive.Text/set
Error setting property 'String' of class 'Text':
I do no tunderstand what goes wrong, I used the disp() function to see what goes fine disp(str) works but disp(out) doesn't show anything on the command window.
Coul danybody tell what I do wrong, thanks in advance

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 2 de Jun. de 2021
Editada: Cris LaPierre el 2 de Jun. de 2021
Your function is working, but it is returning a 1x3 cell array. Title does not accept a cell array of cells.
When building your strings using strcat, only put the character vectors in curly braces. Here's a simplified example.
%This part happens in the plot function which was working until I tried to
%fix the title, in properties header is defined
app.strOpt = 'Cumulative';
app.strData = 'Cases';
header = PlotTitles(app);
{'Cases of COVID-19 Cumulative'} {'Cases of COVID-19 Cumulative in United States'}
title(header);
function Out = PlotTitles(app)
str = strcat(app.strData, {' of COVID-19 '}, app.strOpt);
disp(str)
app.CountryListBox.Value = 'United States';
Out = strcat(str, {' in '},app.CountryListBox.Value);
disp(Out)
end
  1 comentario
Raymond Gilbers
Raymond Gilbers el 3 de Jun. de 2021
Thank you very much I really did not see this error great lesson for me .

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by