Why am i getting this error in the following line of code?

disp (' ');
name = input ('Enter a name for the folder (single quotes): '); % input folder's name
mkdir (name);
It was running fine when i tested it... 'Test' by giving this string name
disp (' ');
name = inputdlg ('Enter a name for the folder (single quotes): '); % input folder's name
mkdir (name);
now when i enter a string 'Test' as my folder name in this dialogue box i get error which says...
Error using mkdir
Argument must contain a string.

 채택된 답변

Mischa Kim
Mischa Kim 2014년 3월 9일
Rizwana, in this case use
name = inputdlg ('Enter a name for the folder (single quotes): ');
mkdir (name{1});
Note the curly brackets.

댓글 수: 3

Rizwana
Rizwana 2014년 3월 9일
편집: Rizwana 2014년 3월 9일
what difference does it makes... what if i make another such dialogue box,how should i write it then??..
s1 = inputdlg('Enter title of column with serial number')
then when i write 'NaN' as default value then also its throwing same error!! how to resolve all such errors?
As pointed out above and explained by Jan below, inputdlg returns a cell array of strings. The following code snippet shows how to read and output multiple (2) lines of strings:
prompt = {'Input dialog'};
name = 'Input dialog';
numlines = 2;
dlg_ans = inputdlg(prompt, name, numlines);
dlg_ans{1}(1,:)
dlg_ans{1}(2,:)
Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2014년 3월 9일
Please read the documentation of inputdlg . There you find the explanation, that a cell is replied. But mkdir requires a string.
You have to pick a certain element out of the cell.
See:
doc inputdlg
doc cell
doc mkdir

카테고리

태그

질문:

2014년 3월 9일

댓글:

2014년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by