Matlab engine with matlab R2010b
I'm working with an aplication that use the matlab engine. I made the C++ program and it is working well in my pc with matlab 2007b, but the same very basic program shows an error when I tried to compile it in a pc with matlab R2010b. The error is about the icuuc32.dll. ¿Why is asking this DLL? How can I solve this?. Thanks¡
...'Matlab Code' to 'Embedded Matlab fun code'
I have a Matlab code to process a pure analog signal 'u'. Now I want to implement it in Simulink and I want to use it in 'Embedded Matlab fun block' so i need to transform 'Matlab code' to 'Embedded Matlab fun code' to perform the task.
The Matlab code is as follows:
u_abs = abs(u);
major_th = 1.5e-1;
minor_th = 1.8e-2;
major_peak_value = ;
minor_peak_value = ;
pos = 1;
pos_max = 1;
[m pos_max(end+1)] = max( u_abs( pos : pos + 10) );
pos_max(end) = pos_max(end) + pos - 1;
if m > major_th
major_peak_value(end+1) = m;
minor_peak_value(end+1) = m;
% exit the peak
pos = find(u_abs(pos:end) < minor_th, 1 , 'first') + pos-1;
% Find the beginning of the next peak
pos = find(u_abs(pos:end) > minor_th, 1 , 'first') + pos-1;
pos_max(2) = ;
plot(u); hold on;
I think i don't need this plot command as I will see the result in the scope directly.
Any suggestion will be very useful.
"Prashant Sandhi" wrote in message <email@example.com>...
> Dear friends,
> I have a Matlab code to process a pure analog signal 'u'. Now I want to implement it in Simu...Simulink - Embedded Matlab Function
I'm trying to convert a .m file into something usable by a user defined function block in simulink but am having trouble with the following style of equation:
x = exp([-y:y]);
where y is an integer which normally has a value between 40 and 120.
Running this through simulink results in the following error:
Computed maximum size of the output of function 'colon' is not bounded.
Static memory allocation requires all sizes to be bounded.
The computed size is [1 x :?].
Function 'testing.m' line 8, column 14:
I know simulink doesn't like variably sized arrays/matrices but I'm not sure I can set an upper bound in this case since it's referring to the operation itself rather than x or y.
Anyone know of a potential work around for this?
What sort of user defined function: Embedded MATLAB, S-Fuction, MATLAB Fcn Block?
Is y and input?
Is x an output?
Or are they local variables?
"Phil Goddard" <firstname.lastname@example.org> wrote in message <email@example.com>...
> What sort of user defined function: Embedded MATLAB, S-Fuction, MATLAB Fcn Block?
> Is y and input?
> Is x an output?
> Or are they local variables?
Sorry should have been more clear. It is an Embedded Matlab Function block, x and y are just local v...Error with embedded matlab function
Initially it says parsing successful for machine and then
It says Model error, source: unknown, reported by: Simulink and then this is the error message,
Error using ==> stateflow\private\slsf
Error using ==> stateflow\private\autobuild_kernel
Error using ==> stateflow\private\targetman
Error using ==> stateflow\private\targetman>method_nag_wrapper
Output argument "fileNameInfo" (and maybe others) not assigned dyring call to "C:\ProgramFiles\MATLAB\R2006a\toolbox\stateflow\stateflow\private\targetman.m (code_method)".
There is another error which says Code Error, source: untitled, reported by: Coder and it says,
Code generation failed PREFDIR failed to create directory 'h:\Application Data\Mathworks\MATLAB'.
...Error encountered in Embedded Matlab Function
I'm doing my final year project by using Embedded Matlab Function and System generator.
I have my m-file and want to make this into the Embedded Matlab Function block so that I can change it into VHDL and test it in FPGA.
When I try to put it in an embedded matlab function block, it shows the following error
Non-integer index expression with value 0.5.
Function 'Embedded MATLAB Function' (#30.441.444), line 25, column 17:
Undefined function or variable 'row'. The first assignment to a local variable determines its class.
Function 'Embedded MATLAB Function' (#30.484.487), line 27, column 32:
Errors occurred during parsing of Embedded MATLAB function 'Embedded MATLAB
How can I solve all those problems? What is it means by "Non-integer index expression with value 0.5" ? How can i do with "Undefined function" ? Lastly, what is the parsing error?
Helps form you guys will be highly appreciated. Thanks you very much !!
And here's my code.
function b = rec(a)
d...Using scripts in Embedded MATLAB Function
Inside an Embedded MATLAB Function block in Simulink, I am using a MATLAB function which is stored as mfile (let's call it "myFcn.m"). Inside "myFcn.m", another mfile is used which includes only scripts to load some variables (let's call it "myVariables.m"). Now when running the Simulink model, I get an error for using those scripts. I wonder if there is a way to fix this error or I have to load variables in some other ways that I have avoided so far? (For some reasons, I would rather to neither use "base" workspace nor InitFcn to load the data).
Many thanks in advance,
I think the solution is to declare extrinsic function using "feval", then the problem is solved, though I have no clue about the performance!
...Problem with embedded matlab function #2
I am simulating a point robot in Simulink and simulating a LIDAR on the robot by drawing a fixed a number of fixed lines out of the robot as it moves to mimic the laser rays. One part of my code is to calculate the two set of points of the many part lines that I draw. Since to get the second set of co ordinates we have to deal with a quadratic equation then we usually get 2 sets of co ordinates and have to choose the right one. In order to choose the right set, I have implemented 4 IF statements to check in which quadrant the robot is facing (by seeing its angle with the axis). The correct IF statements are asserted when changing quadrant, however, the operation inside the IF statement is loosing its value. Here is my code
if (pi/2 > (i-theta) && (i-theta) > 0)
ytrue = max(y);
xtrue = max(x);
flag = 1;
elseif (-pi > (i-theta) && (i-theta) > -3*pi/2 || pi > (i - theta) && (i - theta) > pi/2)
ytrue = max(y);
xtrue = min(x);
flag = 2;
elseif (0 > (i-theta) && (i-theta) > -pi/2 )
ytrue = min(y);
xtrue = max(x);
flag = 3;
elseif (-pi/2 > (i-theta) && (i-theta) > -pi)
ytrue = min(y);
xtrue = min(x);
flag = 4;
Where theta is the angle of the robot with the y -axis and i is the iteration of the for loop since for every position of the robot I must draw a number of rays spanning 180 degrees (i ranges from 0 to pi/2).
The prob...ss command in embedded matlab function
I am using Matlab R2010b 32bit. I found out that the commands (ss) and (tf) can not be used in embedded Matlab functions in Simulink. The error message I got is:
'tf' is not a supported enumeration. In Embedded MATLAB, classdef can only be used in enumeration contexts and must inherit 'int32' or 'Simulink.IntEnumType'.
Below is my code:
function sys = fcn(A1, A2, B, C, D)
A=[A1 A2]; %A1 and A2 are 2-by-1 column vectors
sys = ss(A, B, C, D);
Thank you for your time.
...Why does Matlab do this
What is happening when I type
at the command line?
Matlab goes into a 10 minute spin - what's going on?
"Robert" wrote in message <firstname.lastname@example.org>...
> What is happening when I type
> at the command line?
> Matlab goes into a 10 minute spin - what's going on?
Hi Robert, You're create a 10-D array with that syntax. Do you just want a vector of 10 uniformly distributed random numbers.
x = rand(10,1); % or x = rand(1,10);
You're right - that's what I was trying to do... but I was just newbie mucking about trying to work out the syntax and I typed that in - then had a looong wait for Matlab to work through it!
Thanks for the explanation.
"Robert" wrote in message <email@example.com>...
> Hi Wayne,
> You're right - that's what I was trying to do... but I was just newbie mucking about trying to work out the syntax and I typed that in - then had a looong wait for Matlab to work through it!
> Thanks for the explanation.
That's fine. Welcome to MATLAB!!! If that's the worst memory-intensive mistake you ever make, you'll be fine :) I've done much, much worse.
...make error embedded matlab function
I have a problem that recently appeared which is getting an error message when i try to run an embeded matlab function (in the user defined group) which is:
three error messages:
Make Error, Parse log, Coder log.
In the first error, the detailed description is:
The File name\slprj\_sfprj\Embeded_matlab_fn1\_self\sfun\src>"c:\program files\matlab\r2008a\sys\lcc\bin\lccmake" -f Embeded_matlab_fn1_sfun.lmk
" system cannot find the path specified.
(this folder 'slprj' does not exist before)
"Anas Mesrabi" <firstname.lastname@example.org> wrote in message <email@example.com>...
> I have a problem that recently appeared which is getting an error message when i try to run an embeded matlab function (in the user defined group) which is:
> three error messages:
> Make Error, Parse log, Coder log.
> In the first error, the detailed description is:
> The File name\slprj\_sfprj\Embeded_matlab_fn1\_self\sfun\src>"c:\program files\matlab\r2008a\sys\lcc\bin\lccmake" -f Embeded_matlab_fn1_sfun.lmk
> " system cannot find the path specified.
> (this folder 'slprj' does not exist before)
I have a same problem.
how did you slove it?
I try to run an embedded matlab function.
My com is win7, 64bit.
"Behnam" wrote in message <firstname.lastname@example.org>...
> "Anas Mesrabi" <email@example.com> wrote in mes...Contribute to MATLAB Central and Win a MATLAB Jacket
Many of you who post to this newsgroup are also regular contributors
to the MATLAB Central File Exchange. Look for your favorite
contributors on our File Exchange Author Profile page. You can read
their profiles and see pictures:
In a random drawing, we recently awarded MATLAB jackets to three File
Exchange authors with profile pages: Michele Giugliano, Andrey Egin,
and Denis Gilbert.
You can win a jacket, too. Just submit a new file to the File
Exchange or update your author profile by December 2003 for a chance
to win one of four MATLAB jackets. See the jacket below:
Here are some interesting File Exchange facts:
- Since its inception in 2001, visitors have downloaded more than
1.25 million submissions from the File Exchange.
- In September 2003 alone, visitors downloaded 80,085 files, an
average of 2670 a day!
.... what if the prize was a free copy of the next version of Matlab :-)
Min Poh wrote:
....or an offer for employment...
"bourassa" <firstname.lastname@example.org> wrote in message
> ... what if the prize was a free copy of the next version of Matlab :-)
> Min Poh wrote:
...Embedded MATLAB function block in simulink
Hi all of you.
I was trying to form a MLP (Multi layer perceptron) for a real time application using simulink with some delayed inputs. I was trying to form a block for MLP. For that I need to give a vectro input to an embedded MATLAB function block for the calucation of the output. But it is giving an error message sayeng matrix size mismatch. I checked again and again and for the multiplication size is correct of the vector and the matrix. I need help on this...
...Matlab parallel for loop or Matlab open pool
I am trying to to some computations and I would like to do it in parallel using parfor or by Opening the matlabpool.. as the current implementations is too slow:
for i = 1:length(vector1) % length is 25
for j = 1:length(vector2) % length is 16000
temp1 = vector1(i);
temp2 = vector2(j);
t1 = load(matfiles1(temp1).name) %load image1 from matfile1
t2 = load(matfiles2(temp2).name) % load image2 from matfile2
It work fine but I would really like to know if there is a way to speed thing up ... Thanks a lot in advance!
...Hysterisys controller with embedded matlab function
Hi ! I am trying to implement a hysterisys controller with an embedded matlab function in simulink, It always ends on:
-Output argument 'y' is not assigned on some execution paths.
u1 is the derivative of the input and u2 is the actual value.
I want to set y = inflow as long as the input level is rising with a positive slope and the measured level hasn't passed the setpoint with more than 0.1 units
If the measure exceeds the setpoint value with more than 0.1 I want to turn off, and not turn on again until the measure is o.1 units lower than the setpoint.
u1 is the derivative of the input (setpoint - measure)
and u2 is the errorsignal = setpoint - measure
Can this be implemented?
Below is my shitty code which seemingly doesn't take all situations into account.
Greatful for some help
function y = fcn(u1,u2,inflow)
if ((u2>=0)&& (u2>=0.1))
if ((u2>=0.1)&& (u2>=0))
...Variable Matrix size in Embedded Matlab Functions
I would like to create Matrix in Simulink, which has a variable size.
The Code is the follwoing:
function y = fcn(u)
y = Matrix;
The resulting error after compiling is:
Data 'y' (#85) is inferred as a variable size matrix, while its specified
type is something else.
I don´t understand how I could solve this problem.
Thanks for help and suggestions
...ppval in simulinks embedded matlab function block
I am bit stuck here. I try to use the matlab function "ppval" in an embedded matlab function block in Simulink, but this is obviously not working, since it is not officially supported in the embedded matlab function library.
Therefore I tried different things.
1. copying the code, which underlies the ppval.m, into the embedded matlab function file might be a way and using it as a function (e.g. name it ppval_int()). The same way with the function unmkpp(), as it is not officially eml-compatible. I just copied the code from unmkpp.m into my original function file as another function.
The only obstacle is to make this code being compatible for using in an embedded matlab environment. trying this as a first shot fails due to the statement (and others)
if length(sizexx)==2&&sizexx(1)==1, sizexx(1) = ; end
--> error: "Removing elements from a matrix is not supported."
Might this even though be a practicable way of implementing ppval into an embedded matlab (eml) environment? Or is making this function eml-compatible hopeless?
2. using a c-coded function ppval (e.g. name it ppvalmex) (from here: http://octave.1599824.n4.nabble.com/ppval-td1674970.html) to have compiled a ppvalmex.mexw32 and hence I referenced this using ppvalmex() instead of ppval() or ppval_int()). But this didn't work for the reason, that "Embedded MATLAB can only compile MATLAB files; unsupported file extension 'mexw32'"
--> is...How to read text file into a embedded matlab function
How to read a text file into a embedded matlab function??
I have some values in my text file like--
so, i want to get these values into the embedded matlab function as output and then pass input to other embedded matlab function
In Example ‘a = 10’ and ‘b = 10’ value is in ‘text.txt’ file. U have to declare a,b in model explorer as paremeter. So after running text file all the value will come in workspace then it will read from workspace and model will run.
Just try this code
c = a+b;
"Ashi " <email@example.com> wrote in message <firstname.lastname@example.org>...
> How to read a text file into a embedded matlab function??
> I have some values in my text file like--
> so, i want to get these values into the embedded matlab function as output and then pass input to other embedded matlab function
...Simulink embeded matlab function block generation
I have a simulink automation problem where I need to generate an
embedded matlab function block via a .m file. What I want to be able
to do is autogenerate the entire source.
[output1 output2 output3] = function fcn(A,B,C,D)
output1 = A;
output2 = B;
output3 = A+C+D;
So far, I have not been able to find a way to set the function source
from my M file, but I'm sure there is a way which is undocumented.
Thanks to anyone who can help,
...Need help for a matlab mini project
I have a matlab in class exercise due in few days.
I am new to matlab and the instructions provided with the assignment is minimal.
Can Someone help me with the basic understanding as in how can I map the problem's solution to matlab script ?
I am not able to post question here as it is a jpeg file.
Please let me know and then we can discuss further.
...Call Matlab m-file from Matlab Scrip Node
My problem with matlab script node is related to calling function in matlab. I created an m-file function that takes an imput temperature (from DAQ) and defines a material property. My matlab script node doesn't seem to recognize my function. I have placed the function in the folder the vi is currently located, but it doesn't read it. How do I get matlab script node to read the functions I create in matlab?
Add the directory to matlab path, or call the .m file with it full name ( D:\..... \myfile.m)
Let me clarify,
I have pasted my matlab code into the matlab scrip node.
In this code, I have called a subfunction that I have created.
k_c is a subfunction I have created.
How do I get my code in the node to sucessfully read the subfunction k_c?
As indicated, you need to add the directory where the .m file containing the function resides to the list of paths that are read in. This is your startup.m file. The other option is to do a "cd" command prior to calling your function to change to the directory where the .m file containing the function resides.
Thanks for reiterating the information. My matlab script node is working properly. I had never used the "cd" command in matlab. I always set the working directory when I open the program, and put all the m files into t...version incompatibility for Embedded Matlab Function block in simulink
After creating an 'Embedded Matlab function' block in version 2010a, then opening it in 2011a, saving it and reopening in 2010a, I get the following error when simulating the simulink model. This error is severe enough to crash matlab.
Error occurred in 'blah'. Error occurred while attempting to call the error callback function 'Stateflow.Translate.translate' of subsystem 'blah/Embedded MATLAB Function'. The callback function should take a block handle and error ID as input arguments, and return a string that replaces the error produced within the
subsystem. The following error was produced when the error callback function was called: Undefined function or method 'Stateflow.Translate.translate' for input arguments of type 'double'.
After a tip from http://www.gomatlab.de/hilfe-zur-fehlermeldung-t20311.html to set the 'Name of error callback function:' under 'subsystem parameters' to empty I then got a new error
Embedded MATLAB Interface Error: Error using ==> feval Invalid MEX-file 'blah.mexa64: undefined symbol: emlrtCheckBuiltInCtxR2011a.
I assumed this means that the block was compiled to mex code in R2011a, and is now somehow incompatible. I tried making trivial changes to the code in the block, to force it to recompile, but no dice. Even deleting the block and replacing it with an entirely new block (i.e. y=u) gives the same error.
Models which I didn't open in R2011a still work wi...support embedded matlab function "fsolve"
i want to solve a nonlinear equation with embedded matlab
function in simulink, but i got this error:
Assertion Error Unknown Stateflow
my programm runs good in m file.i don't know the reason,
doesn't embeddede Matlab function support the optimazation
function y = fcn(x1,x2,x3,x4,x5,x6)
y = fsolve(fictiontime,,options);
%x1,x2,x3,x4,x5,x6 are inputs and x is output.
who can give me some suggestion, many thanks!!
No, optimization toolbox functions are not supported by Embedded MATLAB.
Actually it almost feels more natural to me to say that the other way
around, i.e. the Optimization Toolbox doesn't support Embedded MATLAB.
Anyway, as long as you are not generating code (RTW), you can declare an
optimization toolbox functions you want extrinsic and call out to MATLAB
from Embedded MATLAB. See the documentation on eml.extrinsic. You will
probably have to preallocate/declare the output you are expecting before
calling the function.
"ophelia " <email@example.com> wrote in message
>i want to solve a nonlinear equation...xpc target getting error with embedded matlab function
Hello XPC experts and fellow users,
Forgive me i'm just new user in xpc target. I have this Simulink controller model that has few embedded matlab functions insided. I can run the simulation on simulink nicely without problem. But when i compile for xpc target, i cannot generate the emb file. I see that the rtw file is generated but no emb file and with parse error report. I can generate and run in xpc target without issue the other models such as Simpower generators and some demo in XPC i created. But only this model that i have with around 7 embedded matlab function inside the controller blocks. It gets parse error on all the 7 blocks. Is there any special script i needed to add in my embedded matlab function so it can be compiled and run on xpc target? Please help me on this.
...Matlab student license for MDSD (e.g. Matlab Coder)
I'm evaluating products for writing my final university thesis. I want to perform image processing algorithms (C-Code compiled for a DSP). I have the feeling that manual programming of this algorithms is no longer state of the art. Instead MDSD (model driven software development) - that means Code Generation - seems to be smarter to me.
Unfortunately Mathworks offers no licenses of Matlab Coder (or Simulink Coder etc.) to individual students. And I cannot afford to buy a commercial license (which probably would cost me more than 5.000 EUR/$ / my absolute limit is 1.000 EUR/$).
Is there any possibility for me to use MDSD (code generation) for image processing for my university thesis ? Maybe by using cheaper alternatives ? Or by using 3d party software (like target link) ? Or export/import to another product ? Any idea ? (I want to avoid manual coding - like using OpenCV)
By the way, does anyone know, why Mathworks hides the MDSD features from students ? It doesn't make sense to me that Mathworks reduces the amount of engineers available on the job market that are capable of handling (serious) Matlab projects. (Microsoft offers the "Visual Studio Express Edition" for free for education and the amount of people on the job market that are experienced in Visual Studio is tremendous.).