Answered
Matrix multiply slices of 3d Matricies
If you are *not* restricted to gpuArrays you can do this: C = mtimesx(A,B); The MTIMESX function passes pointers to the ...

14 years ago | 2

Answered
How to read an N-dimensioned matrix from a binary file
Read the variable as a 1D using the total number of elements (e.g., 16*20*22*6*3*2) and then reshape the result. Since Fortran s...

14 years ago | 3

| accepted

Answered
MEX - accessing structure of arrays
There will likely be some speed improvement if you put the loop inside a mex functions. At the m-file level, each time you pass ...

14 years ago | 0

| accepted

Answered
How to convert a vector of integers to a vector of characters?
Another method for single digits: A = [0 0 0 0 1 0 0 0 0 1]; B = char(A+'0');

14 years ago | 1

| accepted

Answered
How can I store a complex number on a binary file?
OK, here are the mex files. There are two separate files, one for writing a single variable (numeric or char or logical) to disk...

14 years ago | 0

| accepted

Answered
inv(matrix) takes shorter time than \ operator
1) Your example is so small as to make the timing irrelevant 2) You burden the \ method with creating another variable, B ...

14 years ago | 5

Answered
Pre-allocating Arrays and Optimizing memory
Some clarification on the use of cell arrays and []: A cell array is an array of variable pointers. That is, the "data" of a ...

14 years ago | 2

Answered
element in 2D array
Not exactly sure what you want, but here is code to find the minimum value: x = rand(2,2); m = min(x(:));

14 years ago | 1

Answered
Trimming the Size of a Array of Structures in a MEX file
It is possible to do the equivalent of structOut(cnt+1:end) = [] in a mex routine (see below), but first I would ask if it is re...

14 years ago | 2

| accepted

Answered
Is mat.h thread-safe?
The restriction about not "interacting with MATLAB", as you put it, has to do mainly with the MATLAB memory manager, which is no...

14 years ago | 2

| accepted

Answered
Sparse matrices: find indices of non-zero elements in C code
Here is a simple mex routine that mimics the display functionality for sparse matrices (prints only the non-zero values). You sh...

14 years ago | 1

| accepted

Answered
Can I get faster MatrixMultiplication using CUDA than with Matlab internal GPU implementation??
I'm curious how the times compare to this: C = mtimesx(A,B); MTIMESX can be found here: < http://www.mathworks.com/m...

14 years ago | 1

Answered
Ideas on why this DLL can be used exactly like a MATLAB function?
It is possible that CgCall is itself a mex routine (has a mexFunction interface etc). What version of MATLAB are you running?

14 years ago | 1

| accepted

Answered
How to convert 4 hex bytes into a single integer
Depending on the machine you are on, you may need to use the swapbytes function as well. E.g., try: swapbytes(typecast(uint...

14 years ago | 0

| accepted

Answered
Overload mtimes for double*char
The short answer is DON'T DO THIS! There are many built-in MATLAB functions that do (double)*(char) operations and depend on get...

14 years ago | 0

| accepted

Answered
How to save a c++ readable Mat file
Are you trying to read the compressed mat file into C++ without the aid of the MATLAB API library? If so, this is not at all tri...

14 years ago | 1

Answered
i cant understand meaning of this comment . whenever i run program it show this msg. suggest any solution
You have a function that directly or indirectly calls itself. It did so 500 times without returning in your run. That usually me...

14 years ago | 0

| accepted

Answered
MATLAB Engine: how to call functions?
Maybe you can adapt this FEX submission, which mimics the capability of mexCallMATLAB with an Engine interface: <http://www.m...

14 years ago | 2

Answered
Matrix multiplication result - where does it go?
Interesting question. The answer will probably depend on MATLAB version and JIT settings. TMW likely keeps stuffing more & more ...

14 years ago | 2

| accepted

Answered
Is there a maximum input size for mex? Segmentation Fault with large inputs
There is a bug in the mxArrayToString API function. It only copies the characters up to the first null character. It does not al...

14 years ago | 2

| accepted

Answered
Data type errors in tmwtypes.h while compiling with mex
I suspect the defines -DmwIndex=int -DmwSize=int -DmwSignedIndex=int were intended for older versions of MATLAB (R2006a and earl...

14 years ago | 2

| accepted

Answered
Is there a maximum input size for mex? Segmentation Fault with large inputs
What is the connection between len and the size of prhs[1]? How do we know this isn't simply a user input error? I would suggest...

14 years ago | 0

Answered
How to avoid the compiler error in _kids--Bad rule number 0
The lcc compiler that ships with MATLAB has bugs in it for the unsigned long long type. Your options are: 1) Change to a diff...

14 years ago | 1

| accepted

Answered
Random integer number generation
doc randperm

14 years ago | 1

| accepted

Answered
Mex compilation with header files
Have you tried the function form of mex yet? I.e., something like mex('-I','...whatever...','simulation.cpp') Also, wha...

14 years ago | 0

Answered
Mex compilation with header files
If your current directly is the directory that contains simulation.cpp and its associated header files, doesn't simply "mex simu...

14 years ago | 0

Answered
how to apply relational operators on matrix elements?
i(i>4) = 4; i(i<-4) = -4; or i = min(max(i,-4),4); But in the future avoid i as a variable name since that is wh...

14 years ago | 0

| accepted

Answered
Using Mex with Classes
One option is to keep your pointer in a high level variable (i.e., global) and set up a mexAtExit function to clean things up wh...

14 years ago | 0

| accepted

Answered
Faster way to initilize arrays via empty matrix multiplication?
Another (perhaps related) observation is that MATLAB does some pre 0 filling in the background in mex routines. E.g., I have run...

14 years ago | 3

Answered
C++ Mex compilation error. SharedMemory.cpp
It looks like you are missing the definition of the struct mxArray_tag. This used to be part of the matrix.h file up to R2010a, ...

14 years ago | 2

| accepted

Load more