emlc issue
1 view (last 30 days)
Show older comments
Hi i have been trying to convert my .m file into C generated code. So far it got stuck in the 'switch' function where it shows this error --Expected a numeric value. Found a mxArray
The code is shown below:-
function [] = AIS2
2
3%
4
5
6 % figure(1); clf;
7 % v = cadeia(100,44,0,0,0);%v = [ab,ag] = cadeia(n1,s1,n2,s2,bip) n1 = Population size s1= size of vector
8
9gen =500; P = 150; fact=.2; n = size(P,1);ts = 0.2; Nc=100;beta = 5; pm = 0.05; per = 0.0; N= Nc;
10nump = 3;%number of classes4
11no = 3;%number of images per class
12L = fact;
13fitin = 0.2;
14eml.extrinsic('sprintf')
15eml.extrinsic('disp')
16eml.extrinsic('input')
17
18
19
20
21 disp(sprintf('** Clonal Selection Algorithm**\n'));
22 disp(sprintf('1)Hybrid technique\n'));
23 disp(sprintf('2) CLONALNet\n'));
24disp(sprintf('3)CLONALNet with Pattern Recognition\n'));
25
26 *task = input('Please choose either one of the technique* (1),(2) or (3): ');
27 *switch task*,
28 case 1,
29 [~,~,~,~,vfx,] = optimization2(P,gen,N,pm,per,fact,n,Nc,beta);%function call for optimization and vector for best fitness.
30 case 2,
31 [~,x,y,fx,vfx] = opt(ts,N,Nc,beta,gen);
32 disp(sprintf('Minimum value found [x,y,f(x,y)]: [%2.10f,%2.10f,%2.10f]',x,y,fx));
33 %save filename x y fx
34 %vfx;
35 case 3,
36
37 % %Initialization of population within 3intervals (xmax/xmin/ymax/ymin)
38 [C] = patternrecog(nump,no,gen,beta,fitin); 39
40
41
42 %[Ab,x,y,fx,vfx,vmfit] = patternrecog(pm,per,N,gen,X);
43
44 otherwise,
45 disp('Please enter a valid value');
46 return;
47 end;
Kindly appreciate the help...
1 Comment
Fangjun Jiang
on 27 Jul 2011
What is the '*' symbol in your code, such as *task=input(), *switch task*
Accepted Answer
Fred Smith
on 27 Jul 2011
Hi Jeremiah,
Add the line task = 0; before the line task = input .....
This tells EMLC that you are expecting a double from the extrinsic MATLAB call to "input". Without this hint, EMLC does not have any idea what input will return and therefore will treat it as an mxArray.
Please refer to the documentation on extrinsic calls for a more detailed explanation.
HTH,
Fred
3 Comments
More Answers (1)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!