Multiple values in EditField?

13 visualizaciones (últimos 30 días)
Kristin Habersang
Kristin Habersang el 23 de Feb. de 2021
Editada: Kristin Habersang el 5 de Abr. de 2022
Hello So I want to plot multiple functions into one axis, using a GUI. When I run the GUI there should be one EditField, where I type in the number of sinus functions and then for example one EditField where i can put in multiple amplitudes. These functions should be plotted in the end. But is it even possible to put multiple values into one EditField(text)?

Respuesta aceptada

Mario Malic
Mario Malic el 23 de Feb. de 2021
Hello,
Yes, you can. You'll have to use the str2num function to get the numeric array from the Edit Field (text) component.
>> a = '1, 2, 3' % character array
a =
'1, 2, 3'
>> str2num(a)
ans =
1 2 3 % numeric array
  2 comentarios
Kristin Habersang
Kristin Habersang el 23 de Feb. de 2021
thank you :) ahh okay, so I can just seperate the numbers in with a comma?
And in my code, how do I have access to the single numbers or how can I use them there?
Because I want to type in the numbers after the code and GUI is finished
Mario Malic
Mario Malic el 23 de Feb. de 2021
Comma or space is good enough if you want to input a vector.
The output from
b = str2num(a);
% b is a vector 1x3
b(1) % returns 1
b(2) % returns 2 and so on

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by