Clear Filters
Clear Filters

emlc issue

2 views (last 30 days)
Jeremiah
Jeremiah on 27 Jul 2011
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
Fangjun Jiang on 27 Jul 2011
What is the '*' symbol in your code, such as *task=input(), *switch task*

Sign in to comment.

Accepted Answer

Fred Smith
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
Jeremiah
Jeremiah on 27 Jul 2011
It worked.. Thanks guys...
Jeremiah
Jeremiah on 27 Jul 2011
It means that you have to apply the eml.extrinsic command on each function to eliminate them from being compiled by MATLAB?

Sign in to comment.

More Answers (1)

Jeremiah
Jeremiah on 27 Jul 2011
Hi,
I have another similar issue. I got this error after compilation using emlc -. It says '??? Undefined function or variable 'a'. The first assignment to a local variable determines its class.'
[R,Q]=size(P);
epochs = 500; % number of iterations
goal_err = 10e-5; % goal error
b1=a + (b-a) *rand(S1,1); % Weights between Input and Hidden Neurons
b2=a + (b-a) *rand(S2,1); % Weights between Hidden and Output Neurons
n1=W1*P;
A1=logsig(n1);%can change to Ab1 = (xmax + rand(N,1).*(xmin-xmax))./2;
b=-0.3;
W1=a + (b-a) *rand(S1,R); % Weights between Input and Hidden Neurons
a=0.3; % define the range of random variables
W2=a + (b-a) *rand(S2,S1); % Weights between Hidden and Output Neurons
n2=W2*A1;
A2=logsig(n2);%can change to Ab2 = (ymax + rand(N,1).*(ymin-ymax))./2;
e=A2-T;
error =0.5* mean(mean(e.*e));
Is it something that i have to declare before the variable 'a'. I'm pretty sure that other variables might be affected too as well.

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!