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 Comments

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.
How about you put function to your script? And delete clear,close,clc
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
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?
@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.

Sign in to comment.

 Accepted Answer

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 Comment

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.

Sign in to comment.

More Answers (1)

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 Comment

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

Sign in to comment.

Categories

Products

Release

R2016a

Community Treasure Hunt

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

Start Hunting!