matlab

memory management problem in mexFunction

I'm reading from a binary data file which is written by invoking the following lines in Matlab m-file: disp(sprintf('template = %d', fwrite(fid, template_1d, 'uint8'))); AFAIK, uint8 is the same size as the types BYTE, unsigned char, and unsigned short. Hence I have written the following code in a file-reading method in a C++ class ins...

Simulink version of AnyLogic component

Does anybody know what components in Simulink (MATLAB package) are analogs for AnyLogic components? (e.g: source, buffer, delay, sink). Or how can I easily simulate behavior of AnyLogic model in MATLAB? Maybe there are some cool magic tools? ...

lists find algorithm

I'm trying to translate the usage of find function in Matlab to C++. From what I can see from the C++ find function, I can't seem to find in the description anywhere of an easy method of finding the index in the list in which certain conditions is true rather than just comparing for equality between the item that is being searched for an...

Matlab vs. Visual C++??

I'm doing a Windows Application the uses lots of charts.. Its practically a dataviewer.. I started doing Matlab, because its easier, but I realized it's too slow.. I wanted to change to another language.. Somebody recommended me Visual C++ or Java.. But Im not sure.. What language should I use?? ...

Matlab compiler runtime library

I have developed code on a m-file script in Matlab that communicates with a Measurement Computing USB-DAQ module, and I'm quite happy with that. The problem is that I don't want to purchase another license for the computer which is running the code. I have looked into Matlab Compiler Runtime tools, and it claims that I can deploy my mcc ...

How can I hide the DOS Window and bring up a splash screen?

Ive used the Matlab Compiler to create a .exe file.. The program takes 15 sec to start.. So I figured that I needed to get rid of the DOS window and needed a splash screen.. How can I do that?? ...

Import ITK/VTK into Matlab or Matlab into VTK/ITK environment?

For a current project I have to use and do mathemetics on information provided in matrices as well as use ITK/VTK functions for displaying medical information / renders. Basically I have to use both matlab routines and VTK/ITK in a (I guess) 50/50 way. The problem is that, since I have to use both, I want to decide in advance which metho...

5D array hash table

I currently have a 5D array in the variable called template written into 1D array called template1D, with a hash table of 3456 (8 * 12 * 3 * 4 * 3) entries. In Matlab, the multi-dimensional array was accessed as follows: template{idx_r, idx_l, idx_rho, idx_alpha, idx_beta} However, as I have the indices going from 0-7, 0-11, 0-2, 0-3,...

Image Arithmetic functions in C++

I'm trying to find/write a function that would perform the same operation as imlincomb(). However, I am having trouble finding such functions in C++ without using any Matlab API functions other than Intel Performance Primitiives library, and I don't really want to purchase a license for it unless my application really has to take advanta...

PWM/clock signal generation from a USB-1024HLS DAQ board

Is there an API function call for this board that would allow me to generate a clock signal on an output at 500 kHz while running some other code on the board? Thanks in advance for the advices. ...

Why was Matlab written in C instead of Fortran?

As you may know, Fortran is a language for scientific computing. however, the kernel of the most famous high level language for scientific computing has been written in C instead of Fortran. Why? ...

How to plot a nonlinear system of 3 equations with 3 symbolic variables in MATLAB?

I don't have a lot of experience with Matlab. I know that you can plot equations with 2 variables like this: ezplot(f1) hold on ezplot(f2) hold off; How would you plot three equations with three symbolic variables? An example system would be: x^2+y^2+z^2-1=0 2*x^2+y^2-4*z=0 3*x^2-4y+z^2=0 It would be ideal if there was a way to pl...

How do you save data to a text file in a given format?

I want to save a matrix to a text file, so I can read it by another program. Right now I use: save('output.txt', 'A','-ascii'); But this saves my file as 6.7206983e+000 2.5896414e-001 6.5710723e+000 4.9800797e-00 6.3466334e+000 6.9721116e-001 5.9975062e+000 1.3346614e+000 6.0224439e+000 1.8127490e+000 6.3466334e+000 2.0517928e+...

Comparing two matrices in Matlab

I have two matrices x and y, both are results from different algorithms/routines that are supposed to calculate the same result. While I know that the isequal() would check if x and y are the same matrix, the entries in those matrices would not be exactly the same (i.e. some entries may be with 5% off in worst case scenario). In this sce...

Video processing using VCAPG2 MATLAB

Hi; any suggestion about of how can I use the VCAPG2.dll in background or segmentation processing?, thanks for your help. I'm using the follow code (from an example by de author), for processing in real time, I was trying to convert in binary image, I hope you can help me. clear all; cardnum=vcapg2; % you will get available video cap...

MatLab recursion error (beginner)

Ok. So i've got two function in MatLab that are calling each other. Riemann.m function I = Riemann(f, dx, a, b) x = a:dx:b; fx = f(x).*dx; I = sum(fx); and myfunc.m function f = myfunc(x) f = sin(1./x); for n=1:100 I = Riemann(@myfunc, 0.001, 1/n, 1); end plot(I) The problem is getting that to run. How...

MATLAB "bug" (or really weird behavior) with structs and empty cell arrays

I have no idea what's going on here. I'm using R2006b. Any chance someone out there with a newer version could test to see if they get the same behavior, before I file a bug report? code: (bug1.m) function bug1 S = struct('nothing',{},'something',{}); add_something(S, 'boing'); % does what I expect add_something(S.something,'t...

How do you clear the console in MATLAB?

How do you clear the console in MATLAB? For example, I'm debugging a script that displays a ton of output. I want to clear the console on every run, so I don't have to look through output from old runs. ...

Putting together a big stiffness matrix from several small ones

This is a trivial problem, but I'm just starting with matlab, and haven't got used to their way of thinking yet (and syntax). What I'm asking will be obvious to anyone who's ever done anything with FEM or the like. How do you put together a big stiffness matrix from several small ones. Say, you got for (element 1) a local stiffness ma...

How to get the length of a file in MATLAB?

Is there any way to figure out the length of a .dat file (in terms of rows) without loading the file into the workspace? ...