How do you display a users input into an questdlg command?

8 次查看(过去 30 天)
Hello, I am trying to write a code where a User selects the part they want to order, the number of parts, and their name. I want to then display all of this in an fprintf statement, then ask the user if the display is correct for their order. I got the fprintf version to work, but what I would really like is to maybe get my fprintf code to display as thr questions for the questdlg, then have the user read and answer if their order display is correct in the quest dlg. This is what I have so far
clc
clear
close all
PartType=menu('Please select which part you wish to buy','Flange','Bracket','Hinge');
NumParts=input('How many parts do you wish to buy?: ');
BuyerName=input('Please enter the name for the order: ','s');
Parts={'Flange','Bracket','Hinge'};
PT=Parts{PartType};
displayU=fprintf('The user %s is placing an order on %2.0f units of %s',BuyerName,NumParts,PT);
pause
prompt=questdlg('Please review the statement above. Is this correct?','Order Confirmation');
I would like the promt to look more like.... prompt=questdlg('displayU, Is your order correct?','Order Confirmation') so I can remove the fprintf part :)
Thank you in advance!

采纳的回答

Tommy
Tommy 2020-5-12
fprintf prints text to a file which corresponds to the supplied file ID or, if you don't supply a file ID, the command window (file ID of 1). You can use sprintf to construct a string with syntax similar to fprintf. How about something like this?
displayU=sprintf('The user %s is placing an order on %2.0f units of %s',BuyerName,NumParts,PT);
prompt=questdlg(sprintf('%s\n\nPlease review the statement above. Is this correct?',displayU),'Order Confirmation');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by