Error in the code :Input must be cell arrays of strings

1 visualización (últimos 30 días)
prompt{1}='Enter Movie Rating :';
prompt{2}='Enter Revenue :';
name='Prediction';
ans{1}=inputdlg(prompt{1},name);
ans{2}=inputdlg(prompt{2},name);
x =(ans{1});
y =(ans{2});
a=xlsread('inputdata.xlsx');
disp(a);
output=a(ismember(a(:,1:2),[x y],'rows'),3);
disp(output);
inputdata.xlsx contents
0.1 0.3 0.1
0.1 0.4 0.2
0.1 0.5 0.2
0.1 0.6 0.2
0.1 0.7 0.3
0.1 0.8 0.3
0.2 0.1 0.1
0.2 0.2 0.2
0.2 0.3 0.2
0.2 0.4 0.2
0.2 0.5 0.3
0.2 0.6 0.3
0.2 0.7 0.3
0.2 0.8 0.4
0.3 0.1 0.1
0.3 0.2 0.2
0.3 0.3 0.2
0.3 0.4 0.3
0.3 0.5 0.3
0.3 0.6 0.3
Error message is : Input must be cell arrays of strings.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 20 de Ag. de 2013
When you use inputdlg the result is a cell, then use
x=str2double(inputdlg(prompt{1},name));
y=str2double(inputdlg(prompt{2},name));
Do not use ans,because it's a special variale in Matlab
  2 comentarios
Dimple
Dimple el 20 de Ag. de 2013
Thank u... got the output
Dimple
Dimple el 20 de Sept. de 2013
If suppose iam taking string values like "good","bad","excellent","nice" as the input data instead of 0.1,0.2,0.3.....
Then what to do...?
in my code it is not accepting the string values

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by