I am trying to create an exe from a matlab function which doubles the number you give it. matlab function: test.m function [output] = test (number) %return double the input number output = 2*number; disp(output); run matlab compiler at command line with: mcc -mv test.m with the resulting exe: test.exe However when I run it at DOS prompt: test 1 I am returned a value of 98. I thought that maybe this was some octal description of the output, but 98 oct is not 2 decimal. Some other results it returned: C:\Documents and Settings\alex\Desktop\lighttrans\Frank Work \test...

Hi, I'm trying to use Cantera on windows 7 Professional 64bit using Matlab R2010b. Matlab crashes as soon as function: advance(reactor, t) is getting executed. I have installed Cantera 1.88 and Python 2.6 (both for 64 bit windows). The same code works perfectly fine on a 32bit machine where i have Cantera 1.7 and Python 2.5. I'm using the correct executable(ctmethods.mexw64) file for 64bit machine. Any help will be appreciated. Regards Prakhar (grad student, Caltech) ...

I have the following problem. I have created a simple Matlab GUI (for our purposes it can just be considered a Matlab function) which gathers some parameters and then invokes a perl script that in turn calls other perl and Matlab scripts to perform various calculations. If instead of using the Matlab GUI, I run the perl command from the unix prompt, the flow runs and concludes correctly. BUT if I invoke the flow from the Matlab GUI (function), then it runs correctly by calling various other perl and Matlab scripts, but then when it reaches the third Matlab function call, it consistently stalls...

Hi guys. I really apologize for asking this question, since I'm sure it is either basic or not possible, but I have been reading through the documentation and can't seem to figure this out, since the examples look like they just send and receive variables from the Java methods. Could anyone give me a short example of how to call a method from a Java object that causes some sort of action to be performed in MATLAB? For example, I would like to: 1) make a new object of MyClass from MATLAB called MyObject. 2) run MyObject.DoSomethingInMatlab() 3) have a statement in DoSomethingInMatlab...

Hello, I have a problem calling C code from Matlab. The mex file compilation is ok. When I run the program Matlab (7.3) crashes. Below is the mexFunction code. Any idea is welcome. (I think the main part of the code (middle part) is not useful for the crash problem, but I put it anyway). //########################################################### #include "math.h" #include "mex.h" void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Standard variables int p,r,h,i,j,f,w; // Indices for loop int MAX_NBM = 1000; int MAX_DIM = 10; int MAX_NB_CLUST = 20; double *SF, *km, *new_data; int size, dim, K, nbm, aux_size, count_bis, count_aux; double diam_max, diam, vec1_p, vec2_p, dist_min, dis; int combi[1000000][2]; int dist_aux[1000000][2]; /* Check for proper number of arguments. */ if (nrhs != 5) { mexErrMsgTxt("5 input required."); } else if (nlhs > 1) { mexErrMsgTxt("Too many output arguments"); } // Input parameter (MATLAB) new_data = mxGetPr(prhs[0]); size = (int)mxGetScalar(prhs[1]); dim = (int)mxGetScalar(prhs[2]); K = (int)mxGetScalar(prhs[3]); km = mxGetPr(prhs[4]); // Output parameter (MATLAB) plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); SF = mxGetPr(plhs[0]); // Other variables nbm = size/dim; // Number of points printf("Taille: %d\n",nbm); printf("Dimension: %d\n",dim); //#############################...

If someone can help me here , it will be greatly appreciated ... I was able to set up the Matlab Engine Call via C properly without any issues.. , done it via a C function calll .. something like this ... : ////////////////////////////////////////////////// #include <math.h> ..... int matlab_call(double Amp) { Engine *ep; mxArray *A = NULL, *result = NULL; if (!(ep = engOpen(""))) { fprintf(stderr, "\nCan't start MATLAB engine\n"); return EXIT_FAILURE; } ... } ////////////////////////////////////////////////// Now i want to send in the input argument Amp to Matlab as a variable... I did the following which i am not sure if its correct .. please help.. /////////////////////////////////////////////// A = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); // created a numeric matrix of size 1 and of type double memcpy(&A,&Amp,sizeof(double)); // copied over the memory from the input argument over to the mxArray.. ////////////////////////////////////////////// After this i used the engPutVariable as follows : ////////////////////////////////////////////// engPutVariable(ep, "A", A) ; ////////////////////////////////////////////// But then when i tried and retrieved the data via engGetVariable i get a "Can't read file stdio" error.... ////////////////////////////////////////////// ((result = engGetVariable(ep,"A")) == NULL); // gives a stdio error...

hallo firends, Can any body help me write this below code into MATLAB object oriented code or C code form please? M=50; % total number of periods. (choose for 1s duration) f0 = 50; % fundamental AC frequency T0 = 1/f0; %fundamental AC period T = M*T0; %Time for M periods (integer M) N=30; % sample points per period. dt = T0/N; % Sample at N points per period (integer N > 20) t = dt*[1:M*N-1]; % Sampling time array A0=120/2; % amplitude of AC signal. Divide by 2 or maybe sqrt (2) ? AC=A0*sin(f0*t*2*pi); % create AC signal. DC0=50; % DC amplitude DC=DC0*ones(1,length(t)); % create a DC signal that is constant of length t S=AC+DC; % total signal is AC signal + DC signal figure(1); plot(t,S); % plot signal. xlabel('time');ylabel('Signal'); title('Total Signal'); % filter components fAC=S-mean(S); % here is the AC component fDC=mean(S); % here is the DC component figure(2); plot(t,fAC,'r',t,fDC,'b'); % plot AC and DC signals legend('AC','DC'); xlabel('time');ylabel('Signal'); title('Signal with only AC component'); figure(3); plot(t,fDC,'b'); % plot DC signal legend('DC'); xlabel('time');ylabel('Signal'); title('Signal with only DC component'); figure(4); % best to plot in Fourier domain u=abs(fftshift(fft(S))); NumPoints=length(t); freq=(1/dt)*[1:NumPoints]/NumPoints; % create frequency axis freq=fre...

Hello, could you please tell if matlab crashes on your machine with this function ? ================== function y=ff(x) if (x>2) y=0.999*ff(x-1); else y=x end ================= I tried >>ff(2000) after changing the limit of recursive functions to 3000 then matlab closed with no error message. I use R14. Thank you. YAZ wrote: > Hello, > > could you please tell if matlab crashes on your machine with this > function ? > ================== > function y=ff(x) > if (x>2) > y=0.999*ff(x-1); > else > y=x > end > ================= > I tried > &...

I am new to using mcc, mbuild, and mex - I'm attempting to use these to compile a function in matlab into a dll or exe so that I can re-use it in Matlab just as if it was still an m file. First, I wanted to verify that the code works, and I have received a demo license of the Matlab Compiler to test. As a simple example I've written the following function: function [output_var] = this_is_a_test(input_var) output_var = input_var*2; return I've tried multiple combinations of the mcc call in attempts to compile this function, some compile, some don't. First I tried this call: m...

Hello, I have a problem calling C code from Matlab. The mex file compilation is ok. When I run the program Matlab (7.3) crashes. Below is the mexFunction code. Any idea is welcome. (I think the main part of the code (middle part) is not useful for the crash problem, but I put it anyway). //########################################################### #include "math.h" #include "mex.h" void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Standard variables int p,r,h,i,j,f,w; // Indices for loop int MAX_NBM = 1000; int MAX_DIM = 10; in...

Hi, I implemented some functions using system generator (simulink) and I need to perform some statistical analysis on these functions which involves multi-colouring test. I wrote a matlab file to call these functions inside of a for loop. But for some reason, after a few runs, Matlab just automatically quit without any warning or error messages. Does anyone know why this is happening? At least any suggestion on whether it's Matlab's problem or system generator's problem? Any help would be appreciated. Joy ...

Hey, I'm really stuck on this Matlab question. It's Uni stuff which I've almost completed save for one question and I reeeaaaalllly need you guys' help on this thing. Anyway, I've been given to Matlab functions, impheat and expheat: impheat function [u,tau]= impheat(ndiv,nstep,r) %impheat implicit finite difference solution of 1-D heat equation % [u,tau] = impheat(ndiv,nstep,r); % input % ndiv # of spatial subdivisions % nstep # of time steps % r implicitly defined timestep k=r/(ndiv*ndiv) % output % u solution vector % tau final time % % Last modified 2 November 2006 %...

How to call matlab functions directly from C++ without calling matlab engine. as it is described in this tutorial: http://www.codeproject.com/samples/matlab_cpp.asp I have tried to do something similar in Visual Studio 2005 [Matlab 7, r14] #include <mclcppclass.h> .... mwArray A, B, C; A = magic(mwArray(5)); B = transpose(A); .... but it doesn't compile. I got following errors: error C3861: 'magic': identifier not found error C3861: 'transpose': identifier not found etc... I was looking for header files with declarations of this functions in matlab directory...

How to use new functions of new Matlab version in the old version of Matlab? Maybe it is not a good question but the situation is that I have got a MatlabR2008b on my laptop but the PCs of the university got only MatlabR2007b. I just want to use one particular function in the MatlabR2008b on the university machine. How can I do that? Just copy the toolbox? Or can I build the function as a .dll? Thanks! p.s: Of course I can not persuade the university to buy one MatlabR2008... I am also not the administrator; thus, I can not setup my MatlabR2008 on the university machine even I got th...

I use Labview (version 6.1) to send variables to Matlab (version 7.0.4) via Matlab script and I would like to display some message on the command window of Matlab. The messages are displayed when I call my Matlab function from the command window of Matlab but not when the function is called from Labview. Do you have any idea how to solve this problem ? Regards, Julien. ...

Hi everyone, I'm trying to write code for the c2d function in Matlab - where the inputs are state matrices A, B, C, D, and a delta time-step. The outputs are [phi] and [gamma], the a and b matrices of the new, discrete state representation. I'm not sure where to start. Can anyone offer any suggestions? Thanks ...

Hello everyone, How do I compile MATLAB M files into a form that can then be called from within the MATLAB interpreter? A roundabout way would seem to be to (somehow) Turn the matlab code into C (I think mcc does this), then compile this C code into MEX format and call that. Is there an easier way? I have the MATLAB compiler, so I just need to know what to do with it to get this to work. Thanks in advance, Sina sina.tootoonian wrote: > > > Hello everyone, > > How do I compile MATLAB M files into a form that can then be called > from within the MATLAB interpreter? A roundabout way would seem to > be > to (somehow) Turn the matlab code into C (I think mcc does this), > then > compile this C code into MEX format and call that. Is there an > easier > way? I have the MATLAB compiler, so I just need to know what to do > with > it to get this to work. > > Thanks in advance, > > Sina > > HELP MEX > HELP MEX Or, better, HELP MCC help pcode pseudo code is useful to obfuscate code - protect algorithms, yet still run at full speed and be distributable to other matlab users sina.tootoonian wrote: > > > Hello everyone, > > How do I compile MATLAB M files into a form that can then be called > from within the MATLAB interpreter? A roundabout way would seem to > be > to (somehow) Turn the matlab code into C (I think mcc does this), > then > compile this C code into MEX format and call that...

Hello I am an electronics engineer. Interested in using simulink. I am trying to do FFT inside an S function block (I am new to simulink, but have some experience with matlab). Somone please guide me on this Regards Aravind There is an FFT block in the Signal Processing Blockset is you have access to it. Otherwise you could use either a MATLAB Fcn block or an S-Function. Assuming the input signal is sample based (i.e. scalar at each time step), then the first thing you need to do is buffer the signal into an appropriate length vector before performing the fft. Within an S-funct...

I Installed Matlab R14 in my notebook under Windows XP Sp2 When I open Matlab, the working area comes up but it immediately cloeses so fast before I can even do anything. my laptop has an AMD SEMPRON 3003 processor if that helps. please help. thanks! "jj " <lasborn.nospam@mathworks.com> wrote in message news:fcs8dd$1d6$1@fred.mathworks.com... >I Installed Matlab R14 in my notebook under > Windows XP Sp2 > > When I open Matlab, the working area comes up but > it immediately cloeses so fast before I can even do > anything. > > my laptop has an A...

I need to take a vector of the numbers v={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} and go through all 15 factorial permutations of these numbers. With each of these permutations I need to do a calculation on a vector that contains 25,000 numerical entries. Does anyone know if Matlab has a convenient function for generating, one step at a time, all of the permutations of v? Also, does anyone know if this going to take a really long time to complete? Thanks. Matlab does not have such a function. I wrote one, found at the link below, but it doesn't generate the permutations one at a time. Ther...

***QUESTION***** When I called a subroutine (= an own make function in the same M-file) in a callback function (with handles as in an output argument), Matlab makes a copy of the handles. By returning from the subroutine, Matlab overwrite the handles in the callback function with the copied handles from the subroutine. Is ther an other way without copy the handles. In Visual Basic it is called: Call By Reference. In C it is called a Pointer! ********************************************************** Example: %var1 is a member of handles function btnSubRoutine_Callback(hObject,eventdata,han...

I am trying to use my cmex s function with simulink. enter name of s-function in s-function block dialog block, hit apply, Matlab quits. same thing happens on both G4 733MHz desktop and 1.33GHz powerbook. Crash report below Date/Time: 2004-06-21 23:21:00 +1000 OS Version: 10.3.4 (Build 7H63) Report Version: 2 Command: MATLAB Path: /Applications/MATLAB_SV13/bin/mac/MATLAB Version: ??? (???) PID: 591 Thread: Unknown Link (dyld) error: dyld: /Applications/MATLAB_SV13/bin/mac/MATLAB Undefined symbols: _ssSetRworkValue I am trying to finish my already overdue thesis and am paniking badly, can ...

Hi. I have the following setup: 1) a function of several variables implemented in MATLAB which I want to optimize, i.e. to find variable values for which the function gives minimal value, 2) a very good local optimization procedure implemented in C which I want to use repeatedly to optimize the above mentioned function, and 3) a procedure for generating the local search starting points implemented in MATLAB again. Thus, I need to run a MATLAB function which will iteratively generate a starting point and run a C-function local search procedure from that point. I must pass a function defined in MATLAB to that C-implemented local search. Is it possible? The local search procedure is a standard implementation of certain method - it is well possible that by trying to translate it to MATLAB I would not only loose some performance, but also introduce some bogs, which I certainly do not want to. Thanks for any suggestions. Petr Dear Petr, you can feed your C-Mex function with a function handle and call it from the C part with mexCallMATLAB and the 'feval' command. Calling M-code from C is not really fast, so it will be a bottleneck if your function is called millions of times. Good luck, Jan "Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <i1mnk6$qud$1@fred.mathworks.com>... > you can feed your C-Mex function with a function handle and call it from the C part with mexCallMATLAB and the 'feval' com...

in my simulink project,I have to write a equation by "Matlab Function" block. my periodic equation (with Ts period) is as following: A = 5 ; 0 < t < Dmin*Ts A = exp(-(t - Dmin*Ts)/Ts) ; Dmin*Ts < t < Ts A(t+Ts) = A(t) %================================= i wrote following code in Matlab function block % code : function A = fcn(t) Ts = 2; Dmin = 0.25; m = floor(t/Ts); t1 = t - m*Ts; if t1>=0 && t1<=Dmin*Ts A = 5; elseif t1 > Dmin*Ts && t1 < Ts A = exp(-(t1-Dmin*Ts)/Ts); end %================================= but i received following error : Output argument 'A' is not assigned on some execution paths. how solve this problem?how write my periodic equation in matlab function block? "ghasem" <shaban_sadeghi@yahoo.com> wrote in message <mj4gro$ca4$1@newscl01ah.mathworks.com>... > in my simulink project,I have to write a equation by "Matlab Function" block. > my periodic equation (with Ts period) is as following: > > A = 5 ; 0 < t < Dmin*Ts > A = exp(-(t - Dmin*Ts)/Ts) ; Dmin*Ts < t < Ts > A(t+Ts) = A(t) > > %================================= > i wrote following code in Matlab function block > % code : > > function A = fcn(t) > Ts = 2; > Dmin = 0.25; > m = floor(t/Ts); >...

Benedict XVI's papacy bore witness to two controversies between Christianity and Islam. And while his handling of the situations was not always ...

So you’ve finally landed your dream job as an online marketer and can’t believe your luck. You get to brainstorm fun, innovative ideas, research ...

Twitter’s infrastructure team apologized — deeply — this afternoon for a two-hour outage earlier in the day , which it blamed on “the coincidental ...

Midway through the season-two finale of House Of Cards, Kevin Spacey’s Francis Underwood confronts one of the many people incredibly pissed off ...

The real Violence Against Women Act, the one that doesn’t leave out LGBT, undocumented and Native American Women (since, to paraphrase Burke’s ...

The inane/absurd search for meaning in the mind of a lost and now-hated soul.

And I have to clean it up manually... Today: >Gutter Dweller (gutterdude8947@yahoo.com) has replied to dr2chase’s comment: Here’s the rub: the ...

"There were the orders I never liked getting."

The story of voters in this region revolves around drought, farm loans, migration and dacoits; villagers threaten to exercise the NOTA option ...

Resources last updated: 3/23/2016 7:02:45 AM