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

Answered

Use of arrayfun but with passing a fixed variable to function handle?

matrix(:,3) = arrayfun(@(a,b)max(diff(spikeTimes(a:b))),start_temp,stop_temp);

Use of arrayfun but with passing a fixed variable to function handle?

matrix(:,3) = arrayfun(@(a,b)max(diff(spikeTimes(a:b))),start_temp,stop_temp);

2 days ago | 0

| accepted

Answered

howto organize an array into groups of n-Elements

Another way: x = 1:100; a = reshape (x,5,20); aa = [a;a]; v = cell(1,5); for k=1:5 v{k} = aa(k:k+4,:); end Then the ...

howto organize an array into groups of n-Elements

Another way: x = 1:100; a = reshape (x,5,20); aa = [a;a]; v = cell(1,5); for k=1:5 v{k} = aa(k:k+4,:); end Then the ...

3 days ago | 0

| accepted

Answered

using for loop with if

I'm guessing you want a newline at the end? fprintf(' Ik = %.f \n', abs (Ik))

using for loop with if

I'm guessing you want a newline at the end? fprintf(' Ik = %.f \n', abs (Ik))

4 days ago | 0

Answered

movements of the descent vehicle in the atmosphere of Earth

You have four differential equations involving four variables: V, theta, H, and L. You have to solve these simultaneously since...

movements of the descent vehicle in the atmosphere of Earth

You have four differential equations involving four variables: V, theta, H, and L. You have to solve these simultaneously since...

4 days ago | 0

| accepted

Answered

Error: Matrix dimensions must agree & Error: Function called failed while converting my code to C

This line: mat = (z).^(0:n+1); uses implicit expansion. z is a column vector and (0:n+1) is a row vector, so the result is in...

Error: Matrix dimensions must agree & Error: Function called failed while converting my code to C

This line: mat = (z).^(0:n+1); uses implicit expansion. z is a column vector and (0:n+1) is a row vector, so the result is in...

4 days ago | 0

| accepted

Answered

Can somebody help me to modify this code?

In this Brot = q.B.(q^-1) and this B = (q^-1). Brot.q expression, the dot (.) is likely supposed to represent quaternion mul...

Can somebody help me to modify this code?

In this Brot = q.B.(q^-1) and this B = (q^-1). Brot.q expression, the dot (.) is likely supposed to represent quaternion mul...

5 days ago | 0

Answered

How can I call a *.dll file on a Mac?

dll's are compiled object code specific to the machine type they are compiled for. Are you trying to load the same dll file on ...

How can I call a *.dll file on a Mac?

dll's are compiled object code specific to the machine type they are compiled for. Are you trying to load the same dll file on ...

5 days ago | 0

| accepted

Answered

Inefficiency in MEX function when passing data into output

I am not sure you have enough insight into how codegen is going to code the randi, bsxfun, times, and sum functions to get what ...

Inefficiency in MEX function when passing data into output

I am not sure you have enough insight into how codegen is going to code the randi, bsxfun, times, and sum functions to get what ...

5 days ago | 1

Answered

Invalid Mex file: Undefined symbol: mxrErrMsgTxt

All of the mxGetErrMsg references have been commented out in your posted code, so that is not the problem. I would guess that y...

Invalid Mex file: Undefined symbol: mxrErrMsgTxt

All of the mxGetErrMsg references have been commented out in your posted code, so that is not the problem. I would guess that y...

5 days ago | 0

Answered

I have a C function created using Compiler CDK and it's returning a large array but it's MxArray** type. How do I access all the data retunred to the calling C function?

A function signature like that typically means that the mlfMPrime_CA_P( ) function is creating an mxArray and then returning the...

I have a C function created using Compiler CDK and it's returning a large array but it's MxArray** type. How do I access all the data retunred to the calling C function?

A function signature like that typically means that the mlfMPrime_CA_P( ) function is creating an mxArray and then returning the...

5 days ago | 0

Answered

Why is 'size_t' in external C library interpreted wrong?

I am unaware of MATLAB treating size_t differently, but there is a potential error in your code snippet: int foo(size_t sz, uin...

Why is 'size_t' in external C library interpreted wrong?

I am unaware of MATLAB treating size_t differently, but there is a potential error in your code snippet: int foo(size_t sz, uin...

5 days ago | 0

Answered

How can I speed up an exponential function?

I'm not sure what the issue is since you seem to already know about logical indexing. E.g., test1 = your data x = test1 > 0.0...

How can I speed up an exponential function?

I'm not sure what the issue is since you seem to already know about logical indexing. E.g., test1 = your data x = test1 > 0.0...

6 days ago | 2

| accepted

Answered

Result of asind changed between R2016b and R2019b

This is a bit strange. I would have expected the later version to be better, but it appears to be worse: >> version -release ...

Result of asind changed between R2016b and R2019b

This is a bit strange. I would have expected the later version to be better, but it appears to be worse: >> version -release ...

8 days ago | 0

Answered

could you help me with this explanation?

It's possible you just need to switch to element-wise operators. E.g., OverallEffectinevess = (MassFlowFunction.*ConvectionCoo...

could you help me with this explanation?

It's possible you just need to switch to element-wise operators. E.g., OverallEffectinevess = (MassFlowFunction.*ConvectionCoo...

8 days ago | 0

| accepted

Answered

Solving Coupled ODE's by ode45

Start with your example (assuming that dx/dy was supposed to be dx/dt as you had originally): dx/dt = 3*(dy/dt) + 4*x, dy/dt = ...

Solving Coupled ODE's by ode45

Start with your example (assuming that dx/dy was supposed to be dx/dt as you had originally): dx/dt = 3*(dy/dt) + 4*x, dy/dt = ...

8 days ago | 1

Answered

How can convert binary Numerical Values to Strings?

E.g. >> b = rand(5)<.5 % generate some sample data b = 5×5 logical array 0 0 0 1 1 0 1 0 1 1 1...

How can convert binary Numerical Values to Strings?

E.g. >> b = rand(5)<.5 % generate some sample data b = 5×5 logical array 0 0 0 1 1 0 1 0 1 1 1...

8 days ago | 1

Submitted

IEEE 754r Half Precision floating point converter

Converts MATLAB or C variables to/from IEEE 754r Half Precision floating point bit pattern.

8 days ago | 17 downloads |

Answered

how do you program the file path when you do not know where the person will save the matlab file you send them?

If you don't want to write code to search multiple directories to find the files, your code is going to have to ask the user to ...

how do you program the file path when you do not know where the person will save the matlab file you send them?

If you don't want to write code to search multiple directories to find the files, your code is going to have to ask the user to ...

11 days ago | 0

Answered

how do I get only 1 variable passed through a function?

switch choice; case '1' fprintf('What is the circle''s radius?\n') r = input(' '); [C,E] = circu...

how do I get only 1 variable passed through a function?

switch choice; case '1' fprintf('What is the circle''s radius?\n') r = input(' '); [C,E] = circu...

13 days ago | 0

Answered

How do I create a matrix with all binary combinations?

dec2bin(0:2^N-1) - '0' Note that this is only practical for relatively small values of N. Even moderatly large N can cause thi...

How do I create a matrix with all binary combinations?

dec2bin(0:2^N-1) - '0' Note that this is only practical for relatively small values of N. Even moderatly large N can cause thi...

13 days ago | 1

Answered

Not getting expected results

I get the identity matrix with your code: >> phi = 0; >> psi = 0; >> theta = 0; >> R=[cosd(phi).*cosd(psi)-sind(phi)...

Not getting expected results

I get the identity matrix with your code: >> phi = 0; >> psi = 0; >> theta = 0; >> R=[cosd(phi).*cosd(psi)-sind(phi)...

14 days ago | 1

Answered

Obtain specific dimension from multidimensional Arrays

Not really sure what you are asking, but if you only want to pick off some indexes from an arbitrary dimension, simply supply th...

Obtain specific dimension from multidimensional Arrays

Not really sure what you are asking, but if you only want to pick off some indexes from an arbitrary dimension, simply supply th...

14 days ago | 0

Answered

How to exit a while loop after a certain number of values have been saved to a matrix

The general form for while loops is typically some variation of these: while( condition ) % stuff that eventually alters t...

How to exit a while loop after a certain number of values have been saved to a matrix

The general form for while loops is typically some variation of these: while( condition ) % stuff that eventually alters t...

14 days ago | 0

Answered

Using an array as input argument of a function handle

c = num2cell(a); J_num = J(c{:});

Using an array as input argument of a function handle

c = num2cell(a); J_num = J(c{:});

15 days ago | 0

| accepted

Answered

How to find the average of monte carlo simulation

You could save the r's in a vector. E.g., r(i) = poissrnd(lambda); Or you could generate all of the r's at once without the lo...

How to find the average of monte carlo simulation

You could save the r's in a vector. E.g., r(i) = poissrnd(lambda); Or you could generate all of the r's at once without the lo...

15 days ago | 0

| accepted

Answered

error decimal aproximation, extra decimal

Welcome to the world of floating point arithmetic! See this link: https://www.mathworks.com/matlabcentral/answers/57444-faq-wh...

error decimal aproximation, extra decimal

Welcome to the world of floating point arithmetic! See this link: https://www.mathworks.com/matlabcentral/answers/57444-faq-wh...

15 days ago | 0

Answered

For loop for multiple scenarios

E.g., for k=1:numel(h_max) % use h_max(k), a_max(k), and SM(k) in your code here end Or if they need to vary independent...

For loop for multiple scenarios

E.g., for k=1:numel(h_max) % use h_max(k), a_max(k), and SM(k) in your code here end Or if they need to vary independent...

15 days ago | 0

Answered

How to write a function to determine if the inputed date is valid.Whats wrong with my valid_date function?

Consider these lines: if( any(month == [4,6,9,11]) && day<=30 ) % <-- if you pass this test valid = true; ...

How to write a function to determine if the inputed date is valid.Whats wrong with my valid_date function?

Consider these lines: if( any(month == [4,6,9,11]) && day<=30 ) % <-- if you pass this test valid = true; ...

15 days ago | 0

Answered

calculate the probability of tomorrow's climate

The normal distrubion is a continuous distribution. To answer questions like "probability of temp greater than" or "less than"...

calculate the probability of tomorrow's climate

The normal distrubion is a continuous distribution. To answer questions like "probability of temp greater than" or "less than"...

15 days ago | 0