How enter variables into a dialogue box prompt

I am trying to create a dialogue box to prompt the user to reference a z-table to find the Tail Proportion for a bell curve. I want to put the calulated limits, zl and zu in the prompt so it is easy to identify the z values.
Let's say:
zu = 1.55
zl = 1.45
I currently have:
I noticed fprintf doesn't work here
prompt = {'Use the Z table to find the Tail Proportion for zl and zu\n', fprintdf('Enter value TP value for zu = %2.2',zu),...
fprintf('Enter value TP value for zl = %2.2',zl)};
answer = inputdlg(prompt);

4 Comments

fprintf() is intended to print to the command line or to a file. To create a char variable try sprintf(). Try ...
prompt = {'Use the Z table to find the Tail Proportion for zl and zu\n', sprintf('Enter value TP value for zu = %2.2',zu), ...
sprintf('Enter value TP value for zl = %2.2',zl)};
That is getting the text to appear in the prompt line but the values of the variables are not showing
'help inputdlg' provides the proper sytax. The fourth input can be used to specify default answers.
inputdlg (prompt, 'Please Enter 3 values', 1, {'1', '2', '3'})
I figured it out. I was missing the "f" at the end of %2.2

Sign in to comment.

 Accepted Answer

fprintf() is intended to print to the command line or to a file. To create a char variable try sprintf(). Try ...
prompt = {'Use the Z table to find the Tail Proportion for zl and zu\n', sprintf('Enter value TP value for zu = %2.2f',zu), ...
sprintf('Enter value TP value for zl = %2.2f',zl)};
Credit to Ben Abbott

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!