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

Answered

Internal variables not calculated

Maybe the behavior you are looking for is nested functions. Instead of a function at the end of a script, you have a function w...

Internal variables not calculated

Maybe the behavior you are looking for is nested functions. Instead of a function at the end of a script, you have a function w...

etwa 4 Stunden ago | 0

Answered

Internal variables not calculated

You didn't declare those variables global in the caller. You only have them global in the function. Add the global statements ...

Internal variables not calculated

You didn't declare those variables global in the caller. You only have them global in the function. Add the global statements ...

etwa 11 Stunden ago | 1

Answered

how can i resolve this equation Runge kutta method

You've got a 2nd order equation, so that means you need a 2-element state vector. The two states will be y and y'. All of your...

how can i resolve this equation Runge kutta method

You've got a 2nd order equation, so that means you need a 2-element state vector. The two states will be y and y'. All of your...

etwa 11 Stunden ago | 0

Answered

Appending to an array/vector

We would need to see your code to give a more specific answer, but the general outline is to index into your result vector. E.g....

Appending to an array/vector

We would need to see your code to give a more specific answer, but the general outline is to index into your result vector. E.g....

ein Tag ago | 0

Answered

what wrong in my code when i use ode 45,and what the error are mean

Try changing this [t,y]=ode45('Mass_On_Stick_012345678',tSpan,y0,opts,Parameter); to this [t,y]=ode45(@(t,y)Mass_On_Stick_012...

what wrong in my code when i use ode 45,and what the error are mean

Try changing this [t,y]=ode45('Mass_On_Stick_012345678',tSpan,y0,opts,Parameter); to this [t,y]=ode45(@(t,y)Mass_On_Stick_012...

ein Tag ago | 1

Answered

dgemv produces only zero vectors as results

Two things: 1) All of the integers that you are passing into BLAS/LAPACK functions should be the same. Why are you using ptrdi...

dgemv produces only zero vectors as results

Two things: 1) All of the integers that you are passing into BLAS/LAPACK functions should be the same. Why are you using ptrdi...

3 Tage ago | 1

| accepted

Answered

Create an .m file

To create an .m file for a function named randint, you can do this at the command line as long as the default directory is your ...

Create an .m file

To create an .m file for a function named randint, you can do this at the command line as long as the default directory is your ...

5 Tage ago | 0

Answered

How to read a binary file with below description?

E.g., fname = the name of your binary file fp = fopen(fname,'rb'); k = fread(fp,6,'int16'); y_start = k(1); y_end = k(2);...

How to read a binary file with below description?

E.g., fname = the name of your binary file fp = fopen(fname,'rb'); k = fread(fp,6,'int16'); y_start = k(1); y_end = k(2);...

5 Tage ago | 0

| accepted

Answered

Output argument is not assigned on some execution paths.

What happens if you change this elseif imbalance <= 0 to this else

Output argument is not assigned on some execution paths.

What happens if you change this elseif imbalance <= 0 to this else

5 Tage ago | 0

| accepted

Answered

Does this character vector match any of the following character vectors?

You could use cell arrays. E.g., use ismember(currentMonth,{'June','July','August'}) instead of strcmp(currentMonth,'June'||...

Does this character vector match any of the following character vectors?

You could use cell arrays. E.g., use ismember(currentMonth,{'June','July','August'}) instead of strcmp(currentMonth,'June'||...

5 Tage ago | 0

| accepted

Answered

I am getting wrong answer for factorial(22)

R2016a PCWIN64: >> a1 = factorial(22) a1 = 1.124000727777608e+21 >> b = (sqrt(2*pi*22))*(22^22/exp(22)) b = 1.11...

I am getting wrong answer for factorial(22)

R2016a PCWIN64: >> a1 = factorial(22) a1 = 1.124000727777608e+21 >> b = (sqrt(2*pi*22))*(22^22/exp(22)) b = 1.11...

7 Tage ago | 1

Answered

generating random values with condition

You could use this FEX submission by Roger Stafford for each 4 number block: https://www.mathworks.com/matlabcentral/fileexchan...

generating random values with condition

You could use this FEX submission by Roger Stafford for each 4 number block: https://www.mathworks.com/matlabcentral/fileexchan...

7 Tage ago | 0

Answered

How to Convert a function return is a Handle (C++ mex)

DEVICE_HANDLE is a pointer, so if you are running 64-bit MATLAB then DEVICE_HANDLE will be be 64-bits and will not fit in a 32-b...

How to Convert a function return is a Handle (C++ mex)

DEVICE_HANDLE is a pointer, so if you are running 64-bit MATLAB then DEVICE_HANDLE will be be 64-bits and will not fit in a 32-b...

13 Tage ago | 0

Answered

Runge kutta 4 with two ODE's - function inside a function

Since W is a function of time, it needs to match the time that you are using in each particular line of code. E.g., take this l...

Runge kutta 4 with two ODE's - function inside a function

Since W is a function of time, it needs to match the time that you are using in each particular line of code. E.g., take this l...

15 Tage ago | 1

| accepted

Answered

Converting output from 'find' into a logical

E.g., x = the result of the find y = false(22879,1); y(x) = true; But it may be better to create y with a direct logical exp...

Converting output from 'find' into a logical

E.g., x = the result of the find y = false(22879,1); y(x) = true; But it may be better to create y with a direct logical exp...

15 Tage ago | 0

| accepted

Answered

Remove all infinite values from ydata and then remove those same indices from the xdata so the vectors remain the same length

x = isinf(ydata); ydata(x) = []; xdata(x) = []; Or, if you need to extract the values into new variables, x = ~isinf(ydata);...

Remove all infinite values from ydata and then remove those same indices from the xdata so the vectors remain the same length

x = isinf(ydata); ydata(x) = []; xdata(x) = []; Or, if you need to extract the values into new variables, x = ~isinf(ydata);...

16 Tage ago | 0

Answered

Different results by changing the order of operations

You haven't broken up the calculations properly. I.e., you are comparing different calculations. Your code is essentially: ...

Different results by changing the order of operations

You haven't broken up the calculations properly. I.e., you are comparing different calculations. Your code is essentially: ...

16 Tage ago | 1

| accepted

Answered

Grabbing sections of a matrix by using two doubles as the index

E.g., result = arrayfun(@(x1,x2)data(x1:x2),find(indStart),find(indEnd),'uni',false); This assumes of course that the indStart...

Grabbing sections of a matrix by using two doubles as the index

E.g., result = arrayfun(@(x1,x2)data(x1:x2),find(indStart),find(indEnd),'uni',false); This assumes of course that the indStart...

etwa ein Monat ago | 1

| accepted

Answered

1-2-1 or X-Y-X rotation matrix not supported

According to the doc here: https://www.mathworks.com/help/aerotbx/ug/angle2quat.html?s_tid=doc_ta The angle2quat supports the ...

1-2-1 or X-Y-X rotation matrix not supported

According to the doc here: https://www.mathworks.com/help/aerotbx/ug/angle2quat.html?s_tid=doc_ta The angle2quat supports the ...

etwa ein Monat ago | 1

| accepted

Answered

Plotting a System of Two Second-Order Differential Equations

You've got a 4th order system, so your initial state must contain four elements including the x1' and x2', not two. E.g., [t, ...

Plotting a System of Two Second-Order Differential Equations

You've got a 4th order system, so your initial state must contain four elements including the x1' and x2', not two. E.g., [t, ...

etwa ein Monat ago | 0

| accepted

Answered

hex2num can't recover value from the hex by num2hex

Try typecast(uint32(hex2dec('be361af6')),'single')

hex2num can't recover value from the hex by num2hex

Try typecast(uint32(hex2dec('be361af6')),'single')

etwa ein Monat ago | 1

Answered

Rotation order of quatrotate

I suppose this drawn out explanation is long overdue in this forum, so forgive me for being verbose, but a lot of posters have h...

Rotation order of quatrotate

I suppose this drawn out explanation is long overdue in this forum, so forgive me for being verbose, but a lot of posters have h...

etwa ein Monat ago | 0

Answered

Comparing any of the matrix input

Hints: What does this result give you: classes == x Then look at this: doc any

Comparing any of the matrix input

Hints: What does this result give you: classes == x Then look at this: doc any

etwa ein Monat ago | 0

Answered

()-indexing must appear last in an index expression.

You've got closing and opening parentheses next to each other: ...)(... MATLAB thinks you are trying to use the second part as...

()-indexing must appear last in an index expression.

You've got closing and opening parentheses next to each other: ...)(... MATLAB thinks you are trying to use the second part as...

etwa ein Monat ago | 0

Answered

Single precision matrix multiplication

To illustrate what Matt is saying, a simple timing test: >> format longg >> S = round(10000*single(rand(5000)+rand(5000)*1i));...

Single precision matrix multiplication

To illustrate what Matt is saying, a simple timing test: >> format longg >> S = round(10000*single(rand(5000)+rand(5000)*1i));...

etwa ein Monat ago | 2

Answered

Using MEX file with the main program of Fortran code

You would need to turn the PROGRAM line into a MEXFUNCTION line and add some code for getting the MATLAB variable data to/from t...

Using MEX file with the main program of Fortran code

You would need to turn the PROGRAM line into a MEXFUNCTION line and add some code for getting the MATLAB variable data to/from t...

etwa ein Monat ago | 0

Answered

An explicit Runge Kutta of Fourteen Order code

4th Order RK is here: https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods

An explicit Runge Kutta of Fourteen Order code

4th Order RK is here: https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods

etwa ein Monat ago | 0

| accepted

Answered

Why does mxSetDoubles crash this MEX file?

This line is crashing your code: mxSetDoubles(plhs[0],a); You can't re-use data pointers this way. You have essentially share...

Why does mxSetDoubles crash this MEX file?

This line is crashing your code: mxSetDoubles(plhs[0],a); You can't re-use data pointers this way. You have essentially share...

etwa ein Monat ago | 0

Answered

Highest power of 2 that divides n.

In addition to David's comments, you need to do all of the calculations symbolically, so all of these should be sym: 2, i, r.

Highest power of 2 that divides n.

In addition to David's comments, you need to do all of the calculations symbolically, so all of these should be sym: 2, i, r.

etwa ein Monat ago | 0

| accepted