f



Matlab crashes when print from my custom function in c-mex s-function code

I have a c-mex s-function file in which I have written several custom functions. I have no problems printing to output files from most of these custom functions, but the one below continually crashes Matlab whenever I try to print to file from this function. 

This is odd, because, from what I can see, the syntax below follows that used in all of my other custom functions, so I'm not sure what's going wrong. Can anyone spot the problem with the code below, that causes Matlab to crash when the write-to-file statements are active? (When I comment those lines out, the function runs without crashing, although I suspect that this function is generating the wrong values, which is why I need to view them.)

-------------------------------------------------------------------
static void mdlRLgetState(SimStruct *S){
    
    FILE *out1;  
    
    real_T *Dwork_ShAng = (real_T*) ssGetDWork(S,0);
    real_T *Dwork_ElbAng = (real_T*) ssGetDWork(S,1);
      
    real_T *Dwork_state0 = (real_T*) ssGetDWork(S,48);
    real_T *Dwork_state1 = (real_T*) ssGetDWork(S,49);
        
    /* it also crashes if I declare FILE *out1 here, instead */ 
    out1 = ("AA_mdlRLgetState.log","a"); 
    
    Dwork_state0[0] = Dwork_ShAng[0];
    Dwork_state1[0] = Dwork_ElbAng[0];
        
    fprintf(out1, "Dwork_state0[0] = %f, 1 = %f \n", Dwork_state0[0],Dwork_state1[0]);  
    fclose(out1);  
    
} /* mdlRLgetState() function */ 

-------------------------------------------------------------------

Thanks for any insights you have. 
0
kmj.work (178)
3/16/2012 7:38:18 PM
comp.soft-sys.matlab 211266 articles. 23 followers. lunamoonmoon (257) is leader. Post Follow

2 Replies
995 Views

Similar Articles

[PageSpeed] 39

You're missing fopen here.
Is that a typo in your posting or your actual code?

>     out1 = ("AA_mdlRLgetState.log","a"); 

Phil.
0
phil986 (332)
3/16/2012 8:02:12 PM
omg, my apologies. That was my actual typo. Don't know how I missed that, I don't usually make such glaring oversights. Need more sleep.... :P Thanks for your quick response. 
0
kmj.work (178)
3/16/2012 8:24:17 PM
Reply:

Similar Artilces:

C-mex S-function: nested functions of different typecast
I am trying to create an C-mex S-function with an additional nested function. However, I am having a hard time with all the different pointers and typecasts. Help would be very much appreciated :). Question: Does anyone notice strange type conversions in the code below? The compiler does not complain, but Simulink crashes with a fatal error. static void mdlOutputs(SimStruct *S, int_T tid) { void evaluatespline_1p(double *, double *, const double *, const double *, double *, double *); .... const real_T* Cx = ssGetInputPortRealSignal(S,0); const real_T *Cy = ssGetInputPortRealSignal(S,1); ..... real_T *sr0_norm = ssGetOutputPortSignal(S,1); real_T *Srf = ssGetOutputPortSignal(S,3); .... double teta[4]; double dteta[4]; ..... evaluatespline_1p(sr0_norm, Srf, Cx, Cy, teta, dteta); ..... void evaluatespline_1p(sr,Srf,Cx,Cy,teta,dteta) double *sr[4]; double *Srf; double *Cx[NR_C]; double *Cy[NR_C]; double *teta[4]; double *dteta[4]; { a lot of stuff to calculate the output values for teta and dteta: *teta[k]=atan(dY/dX); *dteta[k]=((dX*ddY-dY*ddX)/(dX*dX+dY*dY))*(NR_C-3)/(*Srf); } ...

MATLAB's SOUND() function in C
Is there a way to implement MATLAB's sound function under C? For those who don't use MATLAB, it's essentially a simplistic, static, mono sound function that converts a series a numbers into a sound at a given sampling rate. nothing fancy. all the Sound APIs begin by discussing all the fancy drivers and buffers and crazy shit i don't really care about. Thanks. In article <1151779016.882805.282580@d56g2000cwd.googlegroups.com>, sluox@yahoo.com wrote: > Is there a way to implement MATLAB's sound function under C? > > For those who don't use MATLAB, it's essentially a simplistic, static, > mono sound function that converts a series a numbers into a sound at a > given sampling rate. nothing fancy. all the Sound APIs begin by > discussing all the fancy drivers and buffers and crazy shit i don't > really care about. > > Thanks. The basic thing to do is: - SndNewChannel - SndDoCommand to send a bufferCommand - SndDisposeChannel If you intend to play the sound asynchronously, be careful to not dispose the sound channel or the buffer you play before the sound has finished playing (install a callback using SndDoCommand, if you want to be informed when that is) For more info, take a look at the function SndSnip_PlaySoundResourceUsingBufferCmds in SoundSnippets.c (<http://developer.apple.com/samplecode/soundsnippets/listing1.html>). Reinder Reinder Ver...

Matlab S-function
I am trying to access element in a matrix. But it gives me an error message "Attempted to access xxx(0); index must be a positive integer or logical." The input to my s-function is a constant block with value of 1 and data type of uint16. Thus, my input is definitely a positive integer. I also tried to use "cast" to make sure my variable "var" is positive integer but it did not work. I have no idea why Simulink returns this error message. My very simple code is below. function setup(block) block.NumInputPorts = 1; block.NumOutputPorts = 1; block.SetPreCompInpPortInfoToDynamic; block.SetPreCompOutPortInfoToDynamic; block.InputPort(1).Dimensions = 1; block.OutputPort(1).Dimensions = 1; block.NumDialogPrms = 0; block.InputPort(1).DatatypeID = 5; % uint16 block.InputPort(1).Complexity = 'Real'; block.InputPort(1).DirectFeedthrough = false; % Override output port properties %block.OutputPort(1).Dimensions = 1; block.OutputPort(1).DatatypeID = 0; % double block.OutputPort(1).Complexity = 'Real'; % Register sample times block.SampleTimes = [-1 0]; % Specify the block simStateCompliance. block.SimStateCompliance = 'DefaultSimState'; % Register for all block methods block.RegBlockMethod('SetInputPortSamplingMode',@SetInpPortFrameData); block.RegBlockMethod('SetInputPortDimensions', @SetInpPortDims); block...

Is it possible to pause & restart a Simulink model from within c-mex s-function code?
I have c-mex s-function code that specifies the behavior of a block within my Simulink model. When a certain condition is met within the c-mex s-function code, a TerminateSimulation variable is set to 1, and the c-mex s-function code sends this output signal to a Simulink Stop block, which stops the model from running. I’ve recently discovered that it’s going to be problematic for me to *stop* the Simulink model from running, between each time I need it to execute (because certain variable values in the workspace that I need to persist, end up being reset). What I now want to do, is to *pause* the Simulink model from my c-mex s-function code, and then restart it after a few seconds have passed. I searched through the Simulink block library, but unlike the existing Stop block, I don’t see any Run/Play or Pause blocks. Is there going to be any way for me to pause and then restart my Simulink model from within my c-mex s-function code? (side question: I see on one documentation page that “When you stop or pause a model, all existing handles for run-time objects become empty.” --> do these “handles” include Dwork vectors? If so, then maybe this whole idea of pausing, rather than stopping, the Simulink model, won’t work anyway…) I see that the mdlSimStatusChange() function exists: http://www.mathworks.com/help/toolbox/simulink/sfg/mdlsimstatuschange.html …but that function is only useful *after* the Simulink model has already been paused or resumed; I don’t s...

This function crashes matlab occasionally... why?!
I have a function that displays several images in one figure (see below). I= 've also been experiencing a lot of MATLAB/Java crashes that I think can be= traced to this function. I'm not sure why it happens... it's quite rare, o= nce a week or two. Can someone tell me what is causing the problem? q=3Drepmat(phantom(256,256),[1 1 9]); ims(q) function ims(im,RANGE,TITLE) % RANGE: e.g. [0 1] for [hi lo] or [0 1;NaN 100;...] for individual ranges % (note: use [] or NaN for no range) % TITLE: ['plot1';'plot2';...] (must be same length) % make into 3D array im =3D squeeze(im); [x y n] =3D size(im); im =3D reshape(im,x,y,n); % try and figure out a nice tiling rows =3D floor(sqrt(n)); cols =3D ceil(n/rows); N =3D [rows cols]; % clear existing plots clf reset % plot here for i =3D 1:N(1) for j =3D 1:N(2) k =3D (i-1)*N(2)+j; if k>n; break; end lo =3D min(min(im(:,:,k))); hi =3D max(max(im(:,:,k))); if exist('RANGE','var') && ~isempty(RANGE) if size(RANGE,1)=3D=3D1 % use same setting for all if ~isnan(RANGE(1,1));lo =3D RANGE(1,1);end if ~isnan(RANGE(1,2));hi =3D RANGE(1,2);end else if k<=3Dsize(RANGE,1) % individual ranges if ~isnan(RANGE(k,1));lo =3D RANGE(k,1);end if ~isnan(RANGE(k,2));hi =3D RANGE(k,2);end ...

S-function! in Simulink/Matlab
Hello, S-function! in Simulink/Matlab does anyone solve ODE in S-function! in Simulink C++ blocks instead of matlab m-files? thanks ...

Shall i use the misrosoft Visual c++ code from a m-file generated from matlab in Visual C++ with out matlab runtime environment
undefined ...

When is a function not a function?
I've got a collection of functions that accept a function or object (paired with a method name) as a callback. For the longest time I have relied on this test. (typeof cb == 'function') This should work as well, but I am not sure how well it degrades in older browsers. I think there are issues with functions created in another context (eg frame) as well. (cb instanceof Function) Then I came across this. (!!fn && typeof fn != "string" && !fn.nodeName && fn.constructor != Array && /function/i.test( fn + "" )) I'm sure it is wrong as it is from jQuery, but it makes me wonder if there are bugs in older browsers that will mislead my test. As an aside, I was looking at the jQuery source as some browser sniffer I was arguing with on a blog cited it as part of an "everybody is doing it" argument. I had glanced at it previously and dismissed it based on its resemblance to Prototype. Upon closer inspection, it makes Prototype look inspired. Suffice to say that anybody who recommends it hasn't read the code. It's a horror show. On Sep 25, 7:09 pm, David Mark <dmark.cins...@gmail.com> wrote: > I've got a collection of functions that accept a function or object > (paired with a method name) as a callback. > > For the longest time I have relied on this test. > > (typeof cb == 'function') > > This should work as well, but I am not sure how well it de...

How to implement Matlab fir1 function in C?
Hi all, In Matlab, we use fir1 function to calculate fir filter coefficients. For example, fir1(10,0.375) Outputs are: ans = Columns 1 through 10 -0.0019 -0.0133 -0.0161 0.0766 0.2677 0.3742 0.2677 0.0766 -0.0161 -0.0133 Column 11 -0.0019 I wonder how it works and how to implement the fir1(n, wn) function in C programming language. Thanks a lot! Please help! Jedora. "Jedora" <jedora@gmail.com> wrote in message news:1180363763.385273.280640@o11g2000prd.googlegroups.com... > Hi all, > > In Matlab, we use fir1 function to calculate fir filter coefficients. > For example, > > fir1(10,0.375) > > Outputs are: > ans = > > Columns 1 through 10 > > -0.0019 -0.0133 -0.0161 0.0766 0.2677 0.3742 > 0.2677 0.0766 -0.0161 -0.0133 > > Column 11 > > -0.0019 > > I wonder how it works and how to implement the fir1(n, wn) function in > C programming language. > Thanks a lot! > Please help! > > Jedora. Get Jake Janovetz' C code for the Parks-McClellan program and modify as you desire for things like I/O, etc. Fred Fred Marshall wrote: > "Jedora" <jedora@gmail.com> wrote in message > news:1180363763.385273.280640@o11g2000prd.googlegroups.com... >> Hi all, >> >> In Matlab, we use fir1 function to calculate fir filter coefficients. >> For example, >> >> fir1(10,0.375) >&...

Passing Mask Parameter to C-mex S Function
Hallo, i have several C-mex S-Functions to which i would like to make ONE mask Block so that i cann enter the name and the parameters of the S-function on the mask dialogbox. So How can i pass the name and the parameters of the s-function from the mask into the s-function block? Thanks in advance!! Ali ...

difference between c mex and m -file for s function
hello, I have a s-function that composed by the m-file method, but the excuation time is too long for the real-time simulation. Thus I converted the s-function from m-file to c-mex method. Then,I use these two methods(m&c) to construct s-functions respectively at a simulink model, and these two s-functions will generate two curves,I try to make this two curves match completely to confirm if the c-mex code is correct, but this two simulation curves(m&c) are identical nearly, not match completely.The solver is ode2 and sample time is about 0.05ms, could you give me so idea or suggest? thanks a lot.... Eric ...

Fortran equivalent to Matlab's eig() function
I'm trying to convert some Matlab code into Fortran 77, as Matlab takes days to solve the multiple finite difference systems I need to solve for. All the Matlab code transfers relatively easily into F77, except for the main solution function (which Matlab makes super easy). I'm not sure if there's some ready-made code I can cut and paste into the F77 program, but essentially I'm trying to substitute for the following line: [V,D]=eig(A,B,'qz') Where Does anyone have any suggestions or advice for how I can implement that in F77? Thanks in advance! Dave On Mon, 08 Sep 2008 08:12:26 -0700, Dave wrote: > program, but essentially I'm trying to substitute for the following > line: > > [V,D]=eig(A,B,'qz') > > Where > > Does anyone have any suggestions or advice for how I can implement that > in F77? > Possibly http://www.netlib.org/lapack/double/dhgeqz.f is what you need. > Thanks in advance! > Dave Jörgen Fantastic. That looks exactly like what I need. Thanks! Dave On Sep 8, 11:03 am, J=F6rgen Tegn=E9r <j.teg...@telia.com> wrote: > On Mon, 08 Sep 2008 08:12:26 -0700, Dave wrote: > > program, but essentially I'm trying to substitute for the following > > line: > > > [V,D]=3Deig(A,B,'qz') > > > Where > > > Does anyone have any suggestions or advice for how I can implement that > > in F77? > > Possiblyhttp://www.netlib.o...

How to measure real time in c-mex s-functions?
I’m developing a c-mex s-function that, once compiled into a .mexw32 file, will call functions from a library (.lib) file and a .dll . These functions control a series of dynamic movements; each movement takes ~5-10 seconds of real-time to run. The controller functions within the .lib and .dll were trained to function properly for only the first 2 seconds of each movement; after 2 seconds, I need to switch control over to another controller. However, I’m trying to determine *how*, within my c-mex s-function code, I can access the system-time, so that I can have an objective measure of when the first 2 seconds have passed for each movement. In case it’s relevant, the c-mex s-function code corresponds to a block within my Simulink model; the .mexw32 file begins running once the Simulink model has started to run. However, referring to the Simulink model time doesn’t seem useful; even though my system runs a total of 5 movements, each of which visually (via animation) takes ~5-10 seconds to execute, the Simulink system time shows only ~1.5 seconds passing per movement (and the specific amount of time per movment may be variable; I’m not sure). In regular C code, I would do the following to gauge time: time_t clockstart; clockstart = clock(); cputime = (double) (clock()-clockstart)/CLOCKS_PER_SEC; However, if I even try to introduce the first line of code above into my c-mex s-function code, I get a compile error. Doing a search for “c-mex s-function time” or “m...

converting matlab code to C code
when i tried to convert the matlab code into c code using matlab coder i got below mentioned error, I am using R2011b(7.13.0.534) my program uses image as an input parameter. ERROR: >> coder -build len.prj ??? This text contains non-empty top-level expressions. It appears to be a script. Error in ==> length_of_line Line: 1 Column: 1 Code generation failed: Open error report. CODE: I=imread('pic29rkey.jpg'); imshow(I);pause hold on [x,y] = ginput(2); line(x,y,'color','r','LineWidth',5); Ired_length = sqrt ((x(2)-x(1))^2 + (y(2)-y(1))^2); [x,y] = ginput(2); line(x,y,'color','g','LineWidth',5); lineLength = sqrt ((x(2)-x(1))^2 + (y(2)-y(1))^2); Igreen_length= lineLength/Ired_length*10; disp(Igreen_length); msgbox(sprintf('Length of the Key is %f cm',Igreen_length)); How to solve this issue? this is the first time i am using this code conversiuon tool thats why! Thanks in advance... "arunkumar " <arun.pk2k3@gmail.com> wrote in message news:jnm1kd$pog$1@newscl01ah.mathworks.com... > when i tried to convert the matlab code into c code using matlab coder i > got below mentioned error, I am using R2011b(7.13.0.534) my program uses > image as an input parameter. > > ERROR: >>> coder -build len.prj ??? This text contains non-empty top-level >>> expressions. It appears to be a script. Error in ==> length_of_line >>> Lin...

how to convert Matlab code to C code
Hi everyone, Can any one tell me how to convert matlab to c?? Regards. On 5/8/2012 4:36 PM, WMS wrote: > Hi everyone, > Can any one tell me how to convert matlab to c?? > > Regards. http://www.mathworks.com/products/matlab-coder/ "MATLAB Coder™ generates standalone C and C++ code from MATLAB code" ...

How can I use a Matlab function, whose inputs varies with time (real time function), in simulink
Hello I need your help I would llike to know how can I use a Matlab function, whose inputs varies with time (real time function), in simulink. Thank you in advance Hiba ...

how to realize decimate(x,2) (matlab function) in C language?
I am new to this function. Hope somebody can tell me the idea how to implementate this function inside DSP using C language. Great Thanks! Try the FAQ on the dspguru site www.dspguru.com I got it. Thanks ...

Is there a way to keep persistent variable values in Matlab (or s-function) workspace?
I have a c-mex s-function that defines a block in my Simulink model. Each time I run my c-mex s-function code (via my .mexw32 file that executes), a set of calculations is performed. I need to run this system numerous, discrete times, with each system-run performing a different set of calculations. I’m hoping to use a Dwork vector variable named Dwork_TestSet[0] to determine which set of calculations to perform (and, at the end of each set of calculations, this vector variable is incremented, so that the next time the system runs, the *next* set of calculations will execute). However, my problem is that every time the system stops running, and then is restarted, the Dwork_TestSet[0] variable always gets reset to 0, thus preventing me from using this as a persistent variable between calculation sets. I’ve attempted the following solutions: ~ eliminate the initialization statement for this variable within mdlStart() ~ eliminate the (alternative) initialization statement for this variable within mdlInitializeConditions() ~ try to manually reset the variable to its incremented value within the Matlab workspace (this returns an error message: “Error: Unbalanced or unexpected parenthesis or bracket.” – apparently, the Dwork vector isn’t defined outside of the c-mex s-function code) The result: none of the above attempts work; the Dwork_TestSet[0] variable is always reset to 0 when each new set of calculations is started. Is it going to be possible for me to allow...

Problems with calling a function from a MATLAB generated dll in c# with matrices as input arguments.
Sorry, there happend something with the subject of my last posting Hi everyone There is this wonderful solution of how to call a function from MATLAB generated dll which I found on <http://www.mathworks.com/support/solutions/data/1-X1PFC.html> It works fine. My problem is now how to call a function (from a MATLAB generated dll) which has a Matrix as In- and Output argument (and not a scalar). Has anyone already experienced with that? I googled a lot, but I could not find anything. Thanks in Advance. Michael P.S. I am using MATLAB Compiler Version 4.0 ...

Error in compiling C++ S-Function with Visual C++
I have a Simulink model with an S-Function which implements, in C language, an algorithm for computing on complex numbers. Because C doesn't have complex numbers built-in manipulation instructions, simply I based the computing on the real-imag. decomposition of the numbers. The S-Function was compiled with lcc through the S-Function Builder, and there were no problems. Since this is a very uncomfortable solution, I decided to use C++ language with Microsoft Visual C++ 2005 Express Edition; the S-Function was still compiled fine. When I introduce the #include <complex> instruction (without changing the C code), I get the following message from the S-Function Builder: cancthrs_wrapper.c C:\Programmi\Microsoft Visual Studio 8\VC\INCLUDE\cmath(18) : error C2143: syntax error: '{' missing before ':' C:\Programmi\Microsoft Visual Studio 8\VC\INCLUDE\cmath(18) : error C2059: syntax error: ':' C:\Programmi\Microsoft Visual Studio 8\VC\INCLUDE\cmath(18) : error C2143: syntax error: '{' missing before ':' C:\Programmi\Microsoft Visual Studio 8\VC\INCLUDE\cmath(18) : error C2059: syntax error: ':' C:\Programmi\Microsoft Visual Studio 8\VC\INCLUDE\cmath(19) : error C2143: syntax error: '{' missing before ':' C:\Programmi\Microsoft Visual Studio 8\VC\INCLUDE\cmath(19) : error C2059: syntax error: ':' C:\Programmi\Microsoft Visual Studio 8\VC\INCLUDE\cmath(19) : error C2143: syntax error: '{' missin...

Functions of audioplayer matlab
Hey, I have a GUI with 3 buttons, all 3 button play songs when loaded from a file, So im using Audioplayer and its playing Button 1, but when i press button 2, Button 1 is still playing and button 2 also plays and so on with button 3... So my question is, what do I do so when Button 1 is playing and I press Button 2, Button 1 music is stopped and Button 2 music starts playing, same with Button 3. (I dont want to add any other buttons, I want it to stop automatically when I press other button and plays that song). function myplay(file) if isunix, %using system's play (from the sox package) on Unix (MATLAB's sound does not work) [s,w]=unix(['play ' file]); else, %using MATLAB's wavplay on Windows [y,fs]=wavread(file); player=audioplayer(y,fs); play(player); pause(max(size(y))/fs); end "Tom Albert" <husein06@hotmail.com> wrote in message news:jp8i6a$3of$1@newscl01ah.mathworks.com... > Hey, > I have a GUI with 3 buttons, all 3 button play songs when loaded from a > file, So im using Audioplayer and its playing Button 1, but when i press > button 2, Button 1 is still playing and button 2 also plays and so on with > button 3... So my question is, what do I do so when Button 1 is playing > and I press Button 2, Button 1 music is stopped and Button 2 music starts > playing, same with Button 3. (I dont want to add any other buttons, I want > it to stop automatically when I press other button and pla...

problem with matlab function
Hello, I am using a matlab function "vitdec" to simulate viterbi decoding i awgn channel. I noticed a rather weird problem with it. When I increase th msglength the BER improves(eventually plateaus down), my understanding i that BEr improves with the traceback length. Attached is the matlab cod and the BERs I observed, traceback length was fixed to 15 for a constrain length of 3. Is there something wrong i am doing or is there a problem wit vitdec? your help will be greatly appreciated. Thanks ***************************************************************************** msglen: 15, 30, 300, 3000, 30000 BER: 2.1e-3, 8.2e-4, 1.5e-4, 9.5e-5, 8.7e-5 **************************************************************************** Matlab Code clear all snr=4; k=3;%constraint length msglen=30000;%msg length tblen=15;%traceback length for snr_idx=1:length(snr) p=sqrt(0.5)*(10^(-1*snr(snr_idx)/20)); no_bit_errors=0;no_bits=0; while no_bit_errors<100 msg = randint(1,msglen); % Random data t = poly2trellis(k,[7 5]); % Define trellis. [code fstate] = convenc(msg,t,0); % Encode the data. noise=p*randn(1,2*msglen); inp_bit=2*code-1; rec_bit=inp_bit+noise; [hrdout]= vitdec( (rec_bit>0), t, tblen, 'trunc', 'hard' ); no_bit_errors=no_bit_errors+sum(abs(msg-hrdout)); no_bits=no_bits+length(msg); end BER(snr_idx)=no...

matlab cwt function
when computing a continuous wavelet transform MatLab uses the function cwt. Ifo ne looks at the code then the line where coefficients are computed looks like coefs(ind,:) = -sqrt(a)*wkeep1(diff(wconv1(val_SIG,f)),lenSIG); what I would like to understand is what analytic formula is used for this computation, in part, what the multiplier sqrt(a) mean and why it is here? Thanks. "Maxim" wrote in message <ilsnt8$6b1$1@ginger.mathworks.com>... > when computing a continuous wavelet transform MatLab uses the function cwt. Ifo ne looks at the code then the line where coefficients are computed looks like > coefs(ind,:) = -sqrt(a)*wkeep1(diff(wconv1(val_SIG,f)),lenSIG); > > what I would like to understand is what analytic formula is used for this computation, in part, what the multiplier sqrt(a) mean and why it is here? > Thanks. Hi Maxim, This expression is easily derived from the CWT as the inner product between the signal and the translated and dilated wavelet. Unfortunately, this forum does not lend itself to posting the derivation. Basically, the code comes from making a piecewise-constant approximation to the input signal, then recognizing that the integral of the wavelet over an interval [k,k+1) can be written as the difference of integrals (-\infty, k+1) - (-\infty, k). Casting this as the difference of two convolutions is obtained by a change of variable in the integral which results in the sqrt(a) term and the minus sign out in front. Wa...

Matlab function #6
Write a MATLAB function computing the product of two arbitrary matrices A, B which are input parameters of your function. In case the sizes of input matrices do not allow to compute the matrix product, provide the corresponding message about the error. You are NOT allowed to use the MATLAB way of multiplication of matrices by simply writing A*B. You will need to write your OWN code to compute the matrix product! My ans function c=matrix_product(A,B) [m1,n1]=size(A); [m2,n2]=size(B); if n1~=m2 error('Wrong sizes of input'); else for i=1:m1 for j=1:n2 c(i,j)=sum(A(i,:).*(B(:,j))'); end end end end may anyone help me to check this please? "Frankie" wrote in message <jl9bac$df5$1@newscl01ah.mathworks.com>... > Write a MATLAB function computing the product of two arbitrary > matrices A, B which are input parameters of your function. In case the sizes of input > matrices do not allow to compute the matrix product, provide the corresponding > message about the error. You are NOT allowed to use the MATLAB way of > multiplication of matrices by simply writing A*B. You will need to write your OWN > code to compute the matrix product! > My ans > function c=matrix_product(A,B) > [m1,n1]=size(A); > [m2,n2]=size(B); > if n1~=m2 > error('Wrong sizes of input'); > else > for i=1:m1 > for j=1:n2 > c(i,j)=sum(A(i,:).*(...

Web resources about - Matlab crashes when print from my custom function in c-mex s-function code - comp.soft-sys.matlab

MSC ADAMS - Wikipedia, the free encyclopedia
Adams/SDK (Software Developer's Kit) can be used for building customized modules. Some such native customizations hitting a special industry ...

Mecheng: Downloads
FG4 Vision Tools is a small MATLAB toolbox for the acquisition of live images from a Phytec Framegrabber 4 video-capture card. Captured images ...

MATLAB Answers - MATLAB Central
Search: MATLAB Central File Exchange Answers Newsgroup Link Exchange Blogs Trendy Cody Contest MathWorks.com Create Account Log In File Exchange ...

Software Testing and Validation with Reactis
Build better control software faster with model-based testing using Reactis. Reactis Tester generates test suites from Simulink and Stateflow ...

The birth of LISP – a summary of John McCarthy’s original paper
... It now seems expedient to expound the system by starting with the class of expressions called S-expressions and the functions called S-functions. ...

MATLAB Central
MATLAB Central home of File Exchange, MATLAB Answers, newsgroup access, Link Exchange, and Blogs for the MATLAB & Simulink user community

Introduction
Introduction

Needs help » Fractal Society and the Fetish of the Individual
This posting is very much a work in progress S-functions are the way s-fractals connect or interact with each other. If S-fractals are nouns, ...

MATLAB Central
MATLAB Central home of File Exchange, MATLAB Answers, newsgroup access, Link Exchange, and Blogs for the MATLAB & Simulink user community

MATLAB Central
Search: File Exchange Answers Newsgroup Link Exchange Blogs Trendy Cody Contest MathWorks.com Create Account Log In File Exchange Answers Newsgroup ...

Resources last updated: 3/30/2016 1:36:12 PM