I get an error, what's wrong? The 'STRING' input must be either a char row vector or a cell array of char row vector

Hi
I tried to build an app that using below code
----
clear
close all
clc
temp = char('');
while (~ strcmp(temp, 'yes'))
temp = input('Input text here: ','s');
end
After using "Application Compiler" to build the App
I ran exe file, the below message display.
I used R2016a, what was wrong? Please advise!

10 件のコメント

Kevin Chng
Kevin Chng 2018 年 10 月 8 日
I don't have error with R2018b, however, may i ask you that do you have error in running them in MATLAB?
That appears to be a script. As far as I understand, it is not possible to use the application compiler with a script, only with a function.
Those clear and close and clc are not doing you any good and should be removed for application compiler.
@Kevin Chng: This code is running well in MATLAB. Only after build in APP, the error is displayed. @Walter Roberson: Thank you! I tried the code that removed clear, close, clc but the same error displayed.
Kevin Chng
Kevin Chng 2018 年 10 月 8 日
編集済み: Kevin Chng 2018 年 10 月 8 日
How about you put function to your script? And delete clear,close,clc
Dennis
Dennis 2018 年 10 月 8 日
編集済み: Dennis 2018 年 10 月 8 日
How does input work in an app? Usually it ask for an input at the command line, but is that an option for a standalone?
Have you tried using inputdlg instead?
@ Kevin Chng: I don't understand what do you mean. I tried to delete clc, clear, close but the same error.
@ Dennis: The code is worked with inputdlg, but i'd like to use input. Thank you so much.
function hi()
temp = char('');
while (~ strcmp(temp, 'yes'))
temp = input('Input text here: ','s');
end
end
@Kevin: Thank you! The same error displayed.
Dennis
Dennis 2018 年 10 月 8 日
I don't think this will work with input. The app is supposed to run without Matlab running or even installed. Hence there is no command line.
Where should you enter anything?
Phan Anh Hoang
Phan Anh Hoang 2018 年 10 月 11 日
@Dennis: This app need to build with runtime included in package to make sure the App will running without Matlab.
Actually, I wrote a code that using several input from keyboard (prompt as DOS) and it was successfully build in to app two months ago. This week, I update the code and rebuild it but the error appeared on the first command that using "input" function. I tried to figure it out by writing a simple test code as posted above. The error is the same, wherever the input function is call.
I think the problem is somewhere of configuration or Matlab's version.

サインインしてコメントする。

 採用された回答

Phan Anh Hoang
Phan Anh Hoang 2018 年 10 月 12 日
I solve it. There is an option in Additional running settings in Application Compiler.
We need to uncheck the "Do not display the Windows Command Shell (console) for execution"
That all. The Input still can using.

1 件のコメント

Daniya Zafar
Daniya Zafar 2022 年 1 月 2 日
編集済み: Daniya Zafar 2022 年 1 月 2 日
Hi Phan, I am using 2021a and get the same error. How do you get to Additional runtime settings?
Weird thing is, everything was working yesterday, I didn't change anything. But now, I get this:
Error using regexprep
The 'STRING' input must be either a char row vector, a cell array of char row vectors, or a string array.

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2018 年 10 月 8 日
I am not sure, but have a try on this :
close all
clc
temp = cell([],1) ;
temp{1} = char('') ;
count = 1 ;
while (~ strcmp(temp{count}, 'yes'))
count = count+1 ;
temp{count} = input('Input text here: ','s');
end

1 件のコメント

Thank KSSV, the same error. I think this is problem of scrip or version. But could not figure it out.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

製品

リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by