How to manipulate data provided by a user via a dialog box?
Mostrar comentarios más antiguos
Hi everyone --
I'm new to Matlab so excuse me if this is a simple question. I'm trying to write a program that allows a user to type in a single variable equation in a dialog box, a range for that equation, and an increment for that equation. The program then needs to generate a table and a plot of the equation.
I have my dialog box set up like this:
>> prompt = {'Enter your equation:','Enter minimum x:','Enter maximum x', 'Enter your increment:'};
>> name = 'Input for user''s function';
>> numLines = 1;
>> userInput = inputdlg(prompt,name,numLines);
As you can see I store the information in the cell userInput. How do I get the data out so that it's in a workable format? For example, I want to create a variable representing the whole range, like this:
>> range = userInput(2):userInput(3)
But Matlab gives me the error "Undefined function 'colon' for input arguments of type 'cell'."
I also want to plot the user's function like this:
>> plot(userInput(1))
But get the error "Error using plot. Conversions to double from cell is not possible."
So, how can I convert these user inputs into something I can work with? I am really stuck. Thank you for your help!
Respuesta aceptada
Más respuestas (1)
Casey
el 22 de Sept. de 2012
0 votos
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!