2,971 total contributions since 2007

Interested in external applications, mex & engine applications with Fortran, C, C++, etc, particularly in the areas of speed improvement and memory management efficiencies.

Answered

Why is subtracting different sized matrices not giving me an error? What is matlab calculating?

See documentation on "implicit expansion" https://www.mathworks.com/help/matlab/matlab_prog/compatible-array-sizes-for-basic-op...

Why is subtracting different sized matrices not giving me an error? What is matlab calculating?

See documentation on "implicit expansion" https://www.mathworks.com/help/matlab/matlab_prog/compatible-array-sizes-for-basic-op...

13 hours ago | 0

Answered

store values from loop in an array

Typos in your code: for i=1:length(A) And change tableA to TableA (MATLAB is case sensitive). Or, you could get rid of the l...

store values from loop in an array

Typos in your code: for i=1:length(A) And change tableA to TableA (MATLAB is case sensitive). Or, you could get rid of the l...

21 hours ago | 0

Answered

Combination of X and Y vectors to get all possible positions on a Cartesian plane

[XX,YY] = ndgrid(X,Y); Z = [XX(:),YY(:)];

Combination of X and Y vectors to get all possible positions on a Cartesian plane

[XX,YY] = ndgrid(X,Y); Z = [XX(:),YY(:)];

22 hours ago | 0

| accepted

Submitted

C Mex MATLAB Version

Mex C code to determine MATLAB version at compile time and run time

24 hours ago | 6 downloads |

Submitted

SHAREDCHILD creates a shared data copy of contiguous subset

SHAREDCHILD creates a shared data copy of a contiguous subsection of an existing variable

1 day ago | 4 downloads |

Answered

mxCreateNumericArray error: cannot convert 'int*' to 'const size_t* {aka const long long unsigned int*}' for argument '2' to 'mxArray*

Simply replace this int* dims = new int[par->ndim]; with this mwSize* dims = new mwSize[par->ndim];

mxCreateNumericArray error: cannot convert 'int*' to 'const size_t* {aka const long long unsigned int*}' for argument '2' to 'mxArray*

Simply replace this int* dims = new int[par->ndim]; with this mwSize* dims = new mwSize[par->ndim];

5 days ago | 1

| accepted

Answered

How do I implement bsxfun column-wise?

C = arrayfun(@(i)func(A(:,i),B(i)),1:size(A,2)) This just hides the loops behind arrayfun ... it doesn't eliminate them.

How do I implement bsxfun column-wise?

C = arrayfun(@(i)func(A(:,i),B(i)),1:size(A,2)) This just hides the loops behind arrayfun ... it doesn't eliminate them.

5 days ago | 1

Answered

how to replace a column in a matrix

Instead of replacing all of the columns of A, use a different variable for the result. E.g., a cell array named C. So instead o...

how to replace a column in a matrix

Instead of replacing all of the columns of A, use a different variable for the result. E.g., a cell array named C. So instead o...

6 days ago | 0

| accepted

Answered

Function Return only one value

Call it with two requested outputs: [X,Y] = MyEKFFun(31,24,18,330,364,379,1,1.1,1.3,2) Since you were calling it with no reque...

Function Return only one value

Call it with two requested outputs: [X,Y] = MyEKFFun(31,24,18,330,364,379,1,1.1,1.3,2) Since you were calling it with no reque...

6 days ago | 3

Answered

any easier way to find cell by string

Assuming the strings all start with 'test', e.g. find(cellfun(@(C)C(end)=='a',A))

any easier way to find cell by string

Assuming the strings all start with 'test', e.g. find(cellfun(@(C)C(end)=='a',A))

6 days ago | 0

| accepted

Answered

cant workout why vectors aren't the same length

If you pass zeros( ) only one argument, it creates a square 2D matrix, not a vector. So give it two arguments to make your resul...

cant workout why vectors aren't the same length

If you pass zeros( ) only one argument, it creates a square 2D matrix, not a vector. So give it two arguments to make your resul...

6 days ago | 0

Answered

Question about array alternating between positive and negative

Seems like there should be a shorter way, but assuming you are looking for all 0 crossings and not just the positive to negative...

Question about array alternating between positive and negative

Seems like there should be a shorter way, but assuming you are looking for all 0 crossings and not just the positive to negative...

7 days ago | 0

| accepted

Answered

Can you compile a code including linprog function?

If you look here, linprog is not one of the Coder supported functions: https://www.mathworks.com/help/coder/ug/functions-suppor...

Can you compile a code including linprog function?

If you look here, linprog is not one of the Coder supported functions: https://www.mathworks.com/help/coder/ug/functions-suppor...

7 days ago | 0

| accepted

Answered

Writing a MATLAB script for equations

E.g., put these lines in a file with a .m extension: lambda = input('Input a value for lambda: '); mtbf = 1 ./ lambda; Are yo...

Writing a MATLAB script for equations

E.g., put these lines in a file with a .m extension: lambda = input('Input a value for lambda: '); mtbf = 1 ./ lambda; Are yo...

7 days ago | 1

| accepted

Answered

Lapacke in level-2 C S-function

According to the interface listed here and the link you list above: http://www.netlib.no/netlib/lapack/double/dpotrs.f The n, ...

Lapacke in level-2 C S-function

According to the interface listed here and the link you list above: http://www.netlib.no/netlib/lapack/double/dpotrs.f The n, ...

7 days ago | 0

| accepted

Answered

Index Exceeds Array Bounds

Normally I would have expected to see code that sets the next values of x and y, but I don't see it. I.e., I am looking for line...

Index Exceeds Array Bounds

Normally I would have expected to see code that sets the next values of x and y, but I don't see it. I.e., I am looking for line...

7 days ago | 0

| accepted

Answered

Finding remaining numbers in logical indexing?

E.g., find1 = length<1; : find2 = (length < 3) & (max_width_head > mean_width_neck*2); : find3 = max_width_head>=me...

Finding remaining numbers in logical indexing?

E.g., find1 = length<1; : find2 = (length < 3) & (max_width_head > mean_width_neck*2); : find3 = max_width_head>=me...

7 days ago | 0

| accepted

Answered

How to use mxCreateNumericArray

This line is incorrect (wrong function and signature): plhs[0] = mxCreateNumericArray(xynum,1,mxINT16_CLASS); /*Creates a ma...

How to use mxCreateNumericArray

This line is incorrect (wrong function and signature): plhs[0] = mxCreateNumericArray(xynum,1,mxINT16_CLASS); /*Creates a ma...

8 days ago | 0

| accepted

Answered

Why is my if statement breaking when condition is not met?

The == operator is an element-wise operator. You need to use a string comparison function for this. E.g., if( strcmpi(verbose...

Why is my if statement breaking when condition is not met?

The == operator is an element-wise operator. You need to use a string comparison function for this. E.g., if( strcmpi(verbose...

8 days ago | 0

| accepted

Answered

Multidimensional arrays do not work in mex functions?

You can't use multi-level [ ][ ]... syntax with simple pointers. E.g., look at these lines: void matsum(double *dphidt, double ...

Multidimensional arrays do not work in mex functions?

You can't use multi-level [ ][ ]... syntax with simple pointers. E.g., look at these lines: void matsum(double *dphidt, double ...

8 days ago | 0

Answered

An efficient (quick) way of entering complex data into Matlab workspace.

Assuming you are using R2018a or later, you might try this FEX submission which can reinterpret real variables as interleaved co...

An efficient (quick) way of entering complex data into Matlab workspace.

Assuming you are using R2018a or later, you might try this FEX submission which can reinterpret real variables as interleaved co...

8 days ago | 0

| accepted

Answered

How to get direction for 3d angles between 2 vectors

You will need to define in your code which direction is the clockwise and which is counterclockwise. You can do that by definin...

How to get direction for 3d angles between 2 vectors

You will need to define in your code which direction is the clockwise and which is counterclockwise. You can do that by definin...

11 days ago | 1

| accepted

Answered

How to code this problem?

E.g., syms x A = [1 2 4 5]; n = numel(A); P = prod(x-A); X = cell(n,1); for k=1:n X{k} = P / (x-A(k)); end This giv...

How to code this problem?

E.g., syms x A = [1 2 4 5]; n = numel(A); P = prod(x-A); X = cell(n,1); for k=1:n X{k} = P / (x-A(k)); end This giv...

11 days ago | 0

Answered

ODE45 generates undesired matrix of NaN entries

This is often an initial condition issue with the specific DE's involved. In your code, you have icond(2) = 0 icond(3) = ((F/...

ODE45 generates undesired matrix of NaN entries

This is often an initial condition issue with the specific DE's involved. In your code, you have icond(2) = 0 icond(3) = ((F/...

11 days ago | 0

Answered

How can I transfer the size of the array to mexFunction

Try this (caveat, untested). Don't pass in the row size of the matrix ... just pass in the matrix only. Let the code figure ou...

How can I transfer the size of the array to mexFunction

Try this (caveat, untested). Don't pass in the row size of the matrix ... just pass in the matrix only. Let the code figure ou...

12 days ago | 0

| accepted

Answered

Preallocating a Matrix(For loop, Vectorization)?

In these lines: Y4=repmat(A,N,1); Y4 = cell2mat(arrayfun(@(i) A^i, (1:N)', 'Uni', false) The first line assigns something to ...

Preallocating a Matrix(For loop, Vectorization)?

In these lines: Y4=repmat(A,N,1); Y4 = cell2mat(arrayfun(@(i) A^i, (1:N)', 'Uni', false) The first line assigns something to ...

13 days ago | 1

| accepted

Answered

how can i use several loops

MATLAB will do all of the loops in the order it encounters them. So for the k=1 iteration it will do the i=1:nx loop in its enti...

how can i use several loops

MATLAB will do all of the loops in the order it encounters them. So for the k=1 iteration it will do the i=1:nx loop in its enti...

13 days ago | 0

| accepted

Answered

Call function and save results

Maybe just display the results: disp(results); Or loop differently: for k = 1:size(results,1) disp(results(k,:)) end

Call function and save results

Maybe just display the results: disp(results); Or loop differently: for k = 1:size(results,1) disp(results(k,:)) end

13 days ago | 0

| accepted

Answered

How combine two cell arrays matlab

E = cellfun(@(x,y)[x y],C,D,'uni',false);

How combine two cell arrays matlab

E = cellfun(@(x,y)[x y],C,D,'uni',false);

13 days ago | 3

| accepted

Answered

How do i do Matrix reordering (cutting into blocks)?

It's not exactly clear what the actual size of your matrix is (maybe you could clarify), but for what you have posted maybe this...

How do i do Matrix reordering (cutting into blocks)?

It's not exactly clear what the actual size of your matrix is (maybe you could clarify), but for what you have posted maybe this...

13 days ago | 0

| accepted