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

Answered

Fast conversion of 2 matrices to 1 complex matrix

See this FEX submission for reading and writing interleaved complex data in R2018a or later without extra data copies: https://...

Fast conversion of 2 matrices to 1 complex matrix

See this FEX submission for reading and writing interleaved complex data in R2018a or later without extra data copies: https://...

2 days ago | 0

Answered

How to replace leading zeroes by spaces with regexprep

One way: fun = @(x)sprintf(['%' num2str(numel(x)) 'd'],str2double(x)); d = cellfun(fun,a,'uni',false); e = cellfun(fun,b,'uni...

How to replace leading zeroes by spaces with regexprep

One way: fun = @(x)sprintf(['%' num2str(numel(x)) 'd'],str2double(x)); d = cellfun(fun,a,'uni',false); e = cellfun(fun,b,'uni...

2 days ago | 0

Answered

trimming matrix arrays arranged within cell arrays

It is not clear whether you want the rows or columns trimmed. Maybe one of these is what you want? TrimmedArray = cellfun(@(x) ...

trimming matrix arrays arranged within cell arrays

It is not clear whether you want the rows or columns trimmed. Maybe one of these is what you want? TrimmedArray = cellfun(@(x) ...

2 days ago | 0

Answered

Runge-Kutta 4th order function error (Matrix dimensions must agree)

Your RK_4 function is not set up to handle vector equations ... it is only set up to handle scalar equations. Also you are not ...

Runge-Kutta 4th order function error (Matrix dimensions must agree)

Your RK_4 function is not set up to handle vector equations ... it is only set up to handle scalar equations. Also you are not ...

2 days ago | 0

Answered

How to pass arguments by reference from Matlab?

doc loadlibrary Create a C header file that gives prototypes for the Fortran subroutines and treat the Fortran arguments as poi...

How to pass arguments by reference from Matlab?

doc loadlibrary Create a C header file that gives prototypes for the Fortran subroutines and treat the Fortran arguments as poi...

8 days ago | 0

Answered

how to create an array of all permutations

If you want all of them in an array (which might be too large if the number of digits is too large), you can use n = number of ...

how to create an array of all permutations

If you want all of them in an array (which might be too large if the number of digits is too large), you can use n = number of ...

9 days ago | 0

| accepted

Answered

Trying to do calculations for density

Why do you have these lines in your function: P_t=4; P_s=3; H=25; Aren't these variable supposed to be input arguments? See...

Trying to do calculations for density

Why do you have these lines in your function: P_t=4; P_s=3; H=25; Aren't these variable supposed to be input arguments? See...

9 days ago | 0

| accepted

Submitted

freadcomplex and fwritecomplex

Mex routines that read and write interleaved complex data files for MATLAB R2018a or later without extra data copy.

9 days ago | 2 downloads |

Answered

efficient ways to read and write complex valued data

A mex routine to accomplish this that doesn't use any hacks can be found here: https://www.mathworks.com/matlabcentral/fileexch...

efficient ways to read and write complex valued data

A mex routine to accomplish this that doesn't use any hacks can be found here: https://www.mathworks.com/matlabcentral/fileexch...

10 days ago | 0

| accepted

Answered

efficient ways to read and write complex valued data

This may not apply to you, but if you have R2018a or later you can just fread( ) into a real variable directly the interleaved d...

efficient ways to read and write complex valued data

This may not apply to you, but if you have R2018a or later you can just fread( ) into a real variable directly the interleaved d...

11 days ago | 0

Answered

Changing contents of Cell Array mex files

When you mxDestroyArray a cell array or struct array, it does a deep destroy. Meaning all of the cell array or struct array ele...

Changing contents of Cell Array mex files

When you mxDestroyArray a cell array or struct array, it does a deep destroy. Meaning all of the cell array or struct array ele...

14 days ago | 0

| accepted

Answered

solution with the Runge-Kutta method HELPP

This is clearly a homework/exam question, so I will only offer hints. The code you have posted is for a single scalar different...

solution with the Runge-Kutta method HELPP

This is clearly a homework/exam question, so I will only offer hints. The code you have posted is for a single scalar different...

15 days ago | 0

Answered

How could I use MATLAB to solve for x with this equation, 0=a*x^(3)+b*x^(-1)+c.

Just use the roots( ) function. If you have a negative integer power of x in the expression such as x^(-n), then multiply every...

How could I use MATLAB to solve for x with this equation, 0=a*x^(3)+b*x^(-1)+c.

Just use the roots( ) function. If you have a negative integer power of x in the expression such as x^(-n), then multiply every...

16 days ago | 0

Answered

Matrix with nested for loops

You don't need loops for this. E.g., p = the probability result = rand(20,20) < p; % your matrix of 0's and 1's

Matrix with nested for loops

You don't need loops for this. E.g., p = the probability result = rand(20,20) < p; % your matrix of 0's and 1's

21 days ago | 0

| accepted

Answered

Bit xor of two binary strings and conversion into decimal

The xor part as a logical vector result result = str1 ~= str2; Or if you wanted it as char: str3 = char((str1 ~= str2) + '0')...

Bit xor of two binary strings and conversion into decimal

The xor part as a logical vector result result = str1 ~= str2; Or if you wanted it as char: str3 = char((str1 ~= str2) + '0')...

21 days ago | 0

| accepted

Answered

Function 'quatrotate' not supported for code generation.

You can always write your own. Just code up the matrix multiply at the bottom of the doc page: https://www.mathworks.com/help/...

Function 'quatrotate' not supported for code generation.

You can always write your own. Just code up the matrix multiply at the bottom of the doc page: https://www.mathworks.com/help/...

22 days ago | 1

Answered

Reshaping a complex 3D array into 1D, and back

I suspect the problem may be that you originally put the data into rows of a matrix. This separates the elements in memory. I....

Reshaping a complex 3D array into 1D, and back

I suspect the problem may be that you originally put the data into rows of a matrix. This separates the elements in memory. I....

22 days ago | 0

Answered

Problem with function handle

f by itself is just a function handle, not the function handle evaluated for any input. You need to give f an input. E.g., b=...

Problem with function handle

f by itself is just a function handle, not the function handle evaluated for any input. You need to give f an input. E.g., b=...

22 days ago | 1

| accepted

Answered

How can I find all possible combinations of rows from two separate arrays?

E.g., For arbitrary values in A and B, doesn't have to be B = -A n = size(A,1); C = repmat({A},2^n,1); mask = dec2bin((0:(2^n...

How can I find all possible combinations of rows from two separate arrays?

E.g., For arbitrary values in A and B, doesn't have to be B = -A n = size(A,1); C = repmat({A},2^n,1); mask = dec2bin((0:(2^n...

22 days ago | 0

Answered

Velocity,Acceleration,Angle

This is a dynamics class. Dynamics involves derivatives. How can you be in a dynamics class without knowing calculus and how t...

Velocity,Acceleration,Angle

This is a dynamics class. Dynamics involves derivatives. How can you be in a dynamics class without knowing calculus and how t...

23 days ago | 1

| accepted

Answered

Randi(imax,m,n)

The point is that once the eps of the max value is greater than 1, you cannot represent contiguous sets of integer values in dou...

Randi(imax,m,n)

The point is that once the eps of the max value is greater than 1, you cannot represent contiguous sets of integer values in dou...

23 days ago | 2

Answered

How this code works and why for? What action does this code take?

You could look here: https://en.wikipedia.org/wiki/Bubble_sort

How this code works and why for? What action does this code take?

You could look here: https://en.wikipedia.org/wiki/Bubble_sort

23 days ago | 1

Answered

Creating all possible combination of a letter/string

One way to create a matrix of these character strings: dem_a='ABC'; % assume starting string is all upper n = numel(dem_a); r...

Creating all possible combination of a letter/string

One way to create a matrix of these character strings: dem_a='ABC'; % assume starting string is all upper n = numel(dem_a); r...

23 days ago | 0

| accepted

Answered

Implementation of a matrix

You haven't told us what x and e are, but assuming x is a vector and e is a scalar, simply this: result = cos( (1:n) .* x(:) * ...

Implementation of a matrix

You haven't told us what x and e are, but assuming x is a vector and e is a scalar, simply this: result = cos( (1:n) .* x(:) * ...

24 days ago | 4

| accepted

Answered

Array indices must be positive integers or logical values.

n = 0 and then you use it as an index: n=0; for i=n:1:tam-1 if xi(n)*xi(n+1)<0 You can't have a 0 index. Also, min is t...

Array indices must be positive integers or logical values.

n = 0 and then you use it as an index: n=0; for i=n:1:tam-1 if xi(n)*xi(n+1)<0 You can't have a 0 index. Also, min is t...

28 days ago | 0

Answered

Formatting floating and integer signed numbers

sprintf("%0.2f%+0.2f",a,b) Having the + inside the %format stuff forces the sign to print.

Formatting floating and integer signed numbers

sprintf("%0.2f%+0.2f",a,b) Having the + inside the %format stuff forces the sign to print.

29 days ago | 0

| accepted

Answered

For-loop in MATLAB

You should not modify the index variable i inside the loop: for i = 1:length(Corr_vector) : i=i+44; % this is ba...

For-loop in MATLAB

You should not modify the index variable i inside the loop: for i = 1:length(Corr_vector) : i=i+44; % this is ba...

29 days ago | 0

Answered

Finding All Combinations of Elements in a Vector

N = 6; result = dec2bin((0:(2^N-1))') - '0'; Then the various vectors you want are the rows of result. Or, if you really want...

Finding All Combinations of Elements in a Vector

N = 6; result = dec2bin((0:(2^N-1))') - '0'; Then the various vectors you want are the rows of result. Or, if you really want...

29 days ago | 1

| accepted

Answered

About floating point format

The 64-bit floating point format is IEEE double: https://en.wikipedia.org/wiki/Double-precision_floating-point_format The 32-b...

About floating point format

The 64-bit floating point format is IEEE double: https://en.wikipedia.org/wiki/Double-precision_floating-point_format The 32-b...

29 days ago | 0