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

Answered

Dealing with very small or very large numbers

I guess the obvious suggestion is to work in units of nanometers or maybe picometers instead of meters. Can you do that?

Dealing with very small or very large numbers

I guess the obvious suggestion is to work in units of nanometers or maybe picometers instead of meters. Can you do that?

1 día ago | 0

| accepted

Answered

How to use if statement in function?

Add this code to the top of your function: if( N <= 0 ) error('N needs to be > 0') end That being said, your loop probab...

How to use if statement in function?

Add this code to the top of your function: if( N <= 0 ) error('N needs to be > 0') end That being said, your loop probab...

2 días ago | 1

| accepted

Answered

How to build a quaternion from a normal vector?

If you have the Aerospace Toolbox, you could do the following n = 1x3 unit normal vector a = angle to rotate in radians v = 1...

How to build a quaternion from a normal vector?

If you have the Aerospace Toolbox, you could do the following n = 1x3 unit normal vector a = angle to rotate in radians v = 1...

2 días ago | 0

Answered

Runge-Kutta 2

Normally one would plot the position, not the velocity. So I would have expected you to plot the "1" index of your solutions. ...

Runge-Kutta 2

Normally one would plot the position, not the velocity. So I would have expected you to plot the "1" index of your solutions. ...

3 días ago | 0

Answered

Double Variable Second order Differential Equation

Just write a derivative function using four states instead of two. The states will be x, y, dxdt, and dydt. The derivitives of...

Double Variable Second order Differential Equation

Just write a derivative function using four states instead of two. The states will be x, y, dxdt, and dydt. The derivitives of...

3 días ago | 0

Answered

How can I divide each element of a vector by each of the elements of another vector in MATLAB?

Assuming a and b are both column vectors, you can use automatic array expansion by transposing one of them and using element-wis...

How can I divide each element of a vector by each of the elements of another vector in MATLAB?

Assuming a and b are both column vectors, you can use automatic array expansion by transposing one of them and using element-wis...

3 días ago | 0

| accepted

Answered

"Array indicies must be positive integers" error

You can't have 0 or fractional indexing in MATLAB. Take this section of code for example: for t = 0:1:200 U(0,t) = ui; ...

"Array indicies must be positive integers" error

You can't have 0 or fractional indexing in MATLAB. Take this section of code for example: for t = 0:1:200 U(0,t) = ui; ...

4 días ago | 0

Answered

what is the difference between the 2 codes ?

zeros([2,2]) passes one argument, a 2-element vector [2,2]. zeros(2,2) passes two arguments, the scalars 2 and 2. The result i...

what is the difference between the 2 codes ?

zeros([2,2]) passes one argument, a 2-element vector [2,2]. zeros(2,2) passes two arguments, the scalars 2 and 2. The result i...

4 días ago | 0

Answered

Getting all Permutations of a 18+ integer vector

The number of different permutations of a vector of size n is n! (n factorial). So what you are attempting has these many possi...

Getting all Permutations of a 18+ integer vector

The number of different permutations of a vector of size n is n! (n factorial). So what you are attempting has these many possi...

4 días ago | 0

Answered

Calculating a matrix with a specific form

You could rearrange the equations, isolate m(1), m(2), and m(3) and solve for them directly. E.g., rearrange the equations to f...

Calculating a matrix with a specific form

You could rearrange the equations, isolate m(1), m(2), and m(3) and solve for them directly. E.g., rearrange the equations to f...

4 días ago | 2

Answered

How to vectorise code involving matrix multiplications with vectors

See this link: https://www.mathworks.com/matlabcentral/answers/776812-how-to-vectorize-a-b-operation-on-slices-of-3d-matrices?s...

How to vectorise code involving matrix multiplications with vectors

See this link: https://www.mathworks.com/matlabcentral/answers/776812-how-to-vectorize-a-b-operation-on-slices-of-3d-matrices?s...

4 días ago | 0

| accepted

Answered

What is the corect code for writing an error message when a user inputs an array instead of a scalar value?

Several ways to test for a scalar. E.g., if( ~isscalar(x) ) error('Input is not a scalar'); end or if( numel(x) ~= 1 )...

What is the corect code for writing an error message when a user inputs an array instead of a scalar value?

Several ways to test for a scalar. E.g., if( ~isscalar(x) ) error('Input is not a scalar'); end or if( numel(x) ~= 1 )...

4 días ago | 0

Answered

Calculating and and recording a vector during each iteration of a "while" loop.

E.g., using a counter to store all of your iteration data in a cell array and then post process this: k = 1; % the counter Rce...

Calculating and and recording a vector during each iteration of a "while" loop.

E.g., using a counter to store all of your iteration data in a cell array and then post process this: k = 1; % the counter Rce...

4 días ago | 0

| accepted

Answered

Trying to separate Quaternion coefficients into array.

Use the double( ) function to convert to numeric array, then use regular indexing. E.g., try this function g = actfun(q) ...

Trying to separate Quaternion coefficients into array.

Use the double( ) function to convert to numeric array, then use regular indexing. E.g., try this function g = actfun(q) ...

4 días ago | 1

| accepted

Answered

quat2eul is giving me a strange result

Maybe all you have to do is add 2*pi to all results that are less than -pi to get things how you want.

quat2eul is giving me a strange result

Maybe all you have to do is add 2*pi to all results that are less than -pi to get things how you want.

9 días ago | 0

| accepted

Answered

Handling Inputs mex function

The prhs[ ] variables are of type pointer to mxArray ... you cannot use simple native C conversions with them. You must use som...

Handling Inputs mex function

The prhs[ ] variables are of type pointer to mxArray ... you cannot use simple native C conversions with them. You must use som...

12 días ago | 0

| accepted

Answered

How can I fix this error?

Delete the extra closing parentheses. I.e., delete the paren where the red underline is.

How can I fix this error?

Delete the extra closing parentheses. I.e., delete the paren where the red underline is.

12 días ago | 0

Answered

Undefined function or variable t

Put this code in a separate file called Math.m % file Math.m function dxdt=Math(t,x1) % function name x=x1(1) y=x1(2) z=x1(...

Undefined function or variable t

Put this code in a separate file called Math.m % file Math.m function dxdt=Math(t,x1) % function name x=x1(1) y=x1(2) z=x1(...

13 días ago | 0

Answered

Generating a 4th order Runge-Kutta Integrator solver for the motion equation.

ode45( ) is not well suited to the orbit problem since the integration errors can systematically build up over time. You can tr...

Generating a 4th order Runge-Kutta Integrator solver for the motion equation.

ode45( ) is not well suited to the orbit problem since the integration errors can systematically build up over time. You can tr...

13 días ago | 0

Answered

ODE45 function for 3 Variables

This y0 = [0;0;0;0]; and this zF = 0; means that your derivative function will evaluate to 0 exactly, so the solution is 0 e...

ODE45 function for 3 Variables

This y0 = [0;0;0;0]; and this zF = 0; means that your derivative function will evaluate to 0 exactly, so the solution is 0 e...

13 días ago | 0

Answered

Can anyone help?

Hint: Look at the results of this operation, and I think you can figure it out from there: x = [2;3;4]; % column vector y = 0:...

Can anyone help?

Hint: Look at the results of this operation, and I think you can figure it out from there: x = [2;3;4]; % column vector y = 0:...

25 días ago | 0

Answered

How binary Random number generation upto n nodes ?

Here is how to get your stated desired output, but this is not random at all: r = dec2bin(0:(2^L-1)) - '0';

How binary Random number generation upto n nodes ?

Here is how to get your stated desired output, but this is not random at all: r = dec2bin(0:(2^L-1)) - '0';

27 días ago | 0

| accepted

Answered

Undefined function or variable 'bisection'.

From the error message, it looks like you are calling the function using the name "bisection", but the actual name of the functi...

Undefined function or variable 'bisection'.

From the error message, it looks like you are calling the function using the name "bisection", but the actual name of the functi...

28 días ago | 0

Answered

ODE45 in 3 dimensions with 6 initial conditions

I find it easier to keep the position elements together, and the velocity elements together, in the state vector. So I would de...

ODE45 in 3 dimensions with 6 initial conditions

I find it easier to keep the position elements together, and the velocity elements together, in the state vector. So I would de...

28 días ago | 1

| accepted

Answered

Generate a Runge-Kutta Integrator solver for the orbital motion equation, when given the initial conditions. Execute for 500 seconds.

First, I find it easier to keep the position elements together, and the velocity elements together, in the state vector. So I w...

Generate a Runge-Kutta Integrator solver for the orbital motion equation, when given the initial conditions. Execute for 500 seconds.

First, I find it easier to keep the position elements together, and the velocity elements together, in the state vector. So I w...

28 días ago | 1

| accepted

Answered

Runge-Kutta method, cannot produce the correct graphs

You need to index x in your calculations. E.g., q1 = f(x(i),y(i)); q2 = f(x(i)+h, y(i)+h*q1); You should init...

Runge-Kutta method, cannot produce the correct graphs

You need to index x in your calculations. E.g., q1 = f(x(i),y(i)); q2 = f(x(i)+h, y(i)+h*q1); You should init...

alrededor de 1 mes ago | 0

| accepted

Answered

Working with an equation and variables from user.

You can construct a function handle as follows: f = str2func(['@(x,y)' str1]); You can then use this function handle to evalua...

Working with an equation and variables from user.

You can construct a function handle as follows: f = str2func(['@(x,y)' str1]); You can then use this function handle to evalua...

alrededor de 1 mes ago | 0

| accepted

Answered

A matlab code that allows the user to put inputs as

See the input( ) function for getting input from the user: https://www.mathworks.com/help/matlab/ref/input.html?searchHighlight...

A matlab code that allows the user to put inputs as

See the input( ) function for getting input from the user: https://www.mathworks.com/help/matlab/ref/input.html?searchHighlight...

alrededor de 1 mes ago | 0

Answered

Using a for loop determine how many months it would take to acquire £500,000.

You don't know the number of iterations it will take, so that is your clue that a for-loop is not appropriate. Use a while-loop...

Using a for loop determine how many months it would take to acquire £500,000.

You don't know the number of iterations it will take, so that is your clue that a for-loop is not appropriate. Use a while-loop...

alrededor de 1 mes ago | 0