Help with parsing code
1 view (last 30 days)
Show older comments
Hi
I want to parse the matlab code using Coder
following matlab code
function abc(arg1, aarg2)
m1('string1', data.struct.field1);
m1('string2', data.struct.field2);
m1('string3', data.struct.field3);
function m1(handle1, handle2)
if(not(strcmp(coder.target,'')),
%use handle2 to generate some required calcs and code
else
% use handle1 to print some stuff to a csv file.
end
Everytime I parse the above code, the coder generates C code for function abc() as follows
void abc(handle2){
m1(data.struct.field1);
b_m1(data.struct.field2);
c_m1(data.struct.field3);
}
the problem is it generated multiple copies of the same function 'm1' because the string input is different in matlab code. How can I ignore the string input when I am parsing and just have one function definition irrespective of the string inputs.
Thanks a lot.
Aditi.
0 Comments
Answers (2)
Walter Roberson
on 11 Jun 2015
m1strings = {'string1', 'string2', 'string3'};
m1fields = {'field1', 'field2', 'field3'};
for K = 1 : length(m1strings)
m1(m1strings{K}, data.struct.(m1fields{K}));
end
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!