How to manipulate data provided by a user via a dialog box?
이전 댓글 표시
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!
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!