- #1
muaaman
- 5
- 0
I am trying to display the input that I enter into the dialog box from "inputdlg" function into a text file.
This is what I've so far:
The input dialog shows up and asks 'What is your name'? I enter it in, and then it closes. I go open the text file 'NameMachineFive.txt' and I get:
But when I enter into Matlab:
I get the name that I entered into the 'inputdlg' dialog box.
So my question is:
]How would I fix the code to get the name input entered into the text file?
I'd highly appreciate the assistance.
This is what I've so far:
Code:
prompt={['What is your name?']};
title = 'Name Machine';
answer = inputdlg(prompt, title);
name = answer{1};
fileID = fopen('NameMachineFive.txt', 'w');
fprintf(fileID,['His name is %s.', name]);
fclose(fileID);
The input dialog shows up and asks 'What is your name'? I enter it in, and then it closes. I go open the text file 'NameMachineFive.txt' and I get:
Code:
His name is
But when I enter into Matlab:
Code:
name
I get the name that I entered into the 'inputdlg' dialog box.
So my question is:
]How would I fix the code to get the name input entered into the text file?
I'd highly appreciate the assistance.