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

Answered

Is it a mistake that the function sum?

Welcome to the world of floating point arithmetic. https://www.mathworks.com/matlabcentral/answers/57444-faq-why-is-0-3-0-2-0-1...

Is it a mistake that the function sum?

Welcome to the world of floating point arithmetic. https://www.mathworks.com/matlabcentral/answers/57444-faq-why-is-0-3-0-2-0-1...

alrededor de 12 horas ago | 1

Answered

return any angle to (0 to 2pi) range

The short answer: mod(x,2*pi) The long answer for this particular mod operation, is that if you want to get the same answer fo...

return any angle to (0 to 2pi) range

The short answer: mod(x,2*pi) The long answer for this particular mod operation, is that if you want to get the same answer fo...

1 día ago | 0

| accepted

Answered

Precision quandaries: why can I print 64 digits?

What you describe sounds like it is just a display issue. Earlier versions of MATLAB on PC machines used a library print functi...

Precision quandaries: why can I print 64 digits?

What you describe sounds like it is just a display issue. Earlier versions of MATLAB on PC machines used a library print functi...

1 día ago | 0

| accepted

Answered

Grabbing number from array to calculate the numerical derivative

For the version you post, see the diff( ) function along with element-wise divide. E.g., diff(y) ./ diff(x) If that doesn't wo...

Grabbing number from array to calculate the numerical derivative

For the version you post, see the diff( ) function along with element-wise divide. E.g., diff(y) ./ diff(x) If that doesn't wo...

2 días ago | 0

| accepted

Answered

Coding a quadratic root finder

I would advise having your logic figure out what situation you have before you start solving things. E.g., something like if( a...

Coding a quadratic root finder

I would advise having your logic figure out what situation you have before you start solving things. E.g., something like if( a...

3 días ago | 0

Answered

Numerical solution of ODEs system using ODE45

You've got a 2nd order DE and a 3rd order DE, so the order of your system is 2+3=5, not 6. So your state vector should have 5 e...

Numerical solution of ODEs system using ODE45

You've got a 2nd order DE and a 3rd order DE, so the order of your system is 2+3=5, not 6. So your state vector should have 5 e...

3 días ago | 1

Answered

Am I doing this right? (a Math formula to Matlab language)

You are on the right track, but have typos in the code due to parentheses issues. A = sum( (x - y).^2 ); B = sum( (x - mean(x)...

Am I doing this right? (a Math formula to Matlab language)

You are on the right track, but have typos in the code due to parentheses issues. A = sum( (x - y).^2 ); B = sum( (x - mean(x)...

4 días ago | 1

| accepted

Answered

Numerical solution of Higher order differential equation using ODE45 and a m. archice

t is a number, not a symbol. So u = sin(t) is a number, not a symbolic function. So doing diff(u) does diff on a single value,...

Numerical solution of Higher order differential equation using ODE45 and a m. archice

t is a number, not a symbol. So u = sin(t) is a number, not a symbolic function. So doing diff(u) does diff on a single value,...

4 días ago | 0

| accepted

Answered

Write an executable script file (m-file) that takes no inputs and returns the displacement and stored energy of a spring system after prompting the user for the 1) input forces (in N) on the spring and 2) the spring constant (in N/m).

To get you started, simply create an m-file with something like this at the front end: F = input('Input the force on the spring...

Write an executable script file (m-file) that takes no inputs and returns the displacement and stored energy of a spring system after prompting the user for the 1) input forces (in N) on the spring and 2) the spring constant (in N/m).

To get you started, simply create an m-file with something like this at the front end: F = input('Input the force on the spring...

6 días ago | 0

| accepted

Answered

How can I add 1 to a particular element in a matrix?

M = your 13x13 matrix M(1,2) = M(1,2) + 1;

How can I add 1 to a particular element in a matrix?

M = your 13x13 matrix M(1,2) = M(1,2) + 1;

7 días ago | 0

| accepted

Answered

How to determine Simplex using Nelder-Mead Algorithm in all direction?

The Nelder-Mead Simplex Method is an adaptive method that adjusts the lengths and directions dynamically. The vertices could be ...

How to determine Simplex using Nelder-Mead Algorithm in all direction?

The Nelder-Mead Simplex Method is an adaptive method that adjusts the lengths and directions dynamically. The vertices could be ...

7 días ago | 0

Answered

Question on why tilde cannot return the opposite statement result

Precedence of ~ is hgher than >, so it gets performed first. You need to use parentheses: ~(adultdata.age>50)

Question on why tilde cannot return the opposite statement result

Precedence of ~ is hgher than >, so it gets performed first. You need to use parentheses: ~(adultdata.age>50)

8 días ago | 0

| accepted

Answered

A single column vector or an array, which is faster?

Other things you are doing in your code are likely to dominate run times. We would need to see your particular application to of...

A single column vector or an array, which is faster?

Other things you are doing in your code are likely to dominate run times. We would need to see your particular application to of...

8 días ago | 0

| accepted

Answered

Matrices and indexing ?!

[LX,LY] = ndgrid(Lx,Ly); z = LX(:)./LY(:) <= 2; LX = LX(z); LY = LY(z); LX and LY contain the number pairs that match the co...

Matrices and indexing ?!

[LX,LY] = ndgrid(Lx,Ly); z = LX(:)./LY(:) <= 2; LX = LX(z); LY = LY(z); LX and LY contain the number pairs that match the co...

9 días ago | 0

Answered

how do you substitute all iterations of symbolic sin^2theta cos^2theta with 1 in this symbolic MATLAB matrix to have a more simplified output?

simplify(K)

how do you substitute all iterations of symbolic sin^2theta cos^2theta with 1 in this symbolic MATLAB matrix to have a more simplified output?

simplify(K)

9 días ago | 0

Answered

Sort rows of matrix by matching column with another matrix column

E.g., assuming everything in column 31 has a match [~,x] = ismember(A(:,31),B(:,31)); Bsort = B(x,:);

Sort rows of matrix by matching column with another matrix column

E.g., assuming everything in column 31 has a match [~,x] = ismember(A(:,31),B(:,31)); Bsort = B(x,:);

9 días ago | 1

| accepted

Answered

how to find max value of a function with a for loop

Make e a vector. E.g., for i=1:length(x) e(i) = y(i) - (m*x(i)-b); % <-- Are you sure that isn't supposed to be (m*x(i) +...

how to find max value of a function with a for loop

Make e a vector. E.g., for i=1:length(x) e(i) = y(i) - (m*x(i)-b); % <-- Are you sure that isn't supposed to be (m*x(i) +...

9 días ago | 1

| accepted

Answered

How to solve a system of ODEs and plot the result

This is where you needed to show us the complete code and the complete error message. It is probably complaining about your init...

How to solve a system of ODEs and plot the result

This is where you needed to show us the complete code and the complete error message. It is probably complaining about your init...

9 días ago | 0

| accepted

Answered

precision of calculation with Matlab

Calculators may not use the same floating point representations or arithmetic routines that MATLAB uses, so differences in the t...

precision of calculation with Matlab

Calculators may not use the same floating point representations or arithmetic routines that MATLAB uses, so differences in the t...

9 días ago | 0

Answered

How to code for this equation in Matlab

Assuming that f(x) is really supposed to be f(t): f = @(t)exp(j*w*t); But, you will need to have w defined prior to this.

How to code for this equation in Matlab

Assuming that f(x) is really supposed to be f(t): f = @(t)exp(j*w*t); But, you will need to have w defined prior to this.

9 días ago | 0

| accepted

Answered

Mex C file generation Linker library error

Do you already have a zzz.lib file? Normally to get your mexFunction code to link to the library you simply include it as part ...

Mex C file generation Linker library error

Do you already have a zzz.lib file? Normally to get your mexFunction code to link to the library you simply include it as part ...

9 días ago | 0

| accepted

Answered

rand command give different answer

rand( ) is a random number generator ... it is supposed to give a different result. doc rand If you want to start over with th...

rand command give different answer

rand( ) is a random number generator ... it is supposed to give a different result. doc rand If you want to start over with th...

11 días ago | 1

Answered

Help creating an array to hold approx error from a taylor series

Generally, just index into your variable inside the loop: a_values(index) = a_err; If the indexing could be large, you would a...

Help creating an array to hold approx error from a taylor series

Generally, just index into your variable inside the loop: a_values(index) = a_err; If the indexing could be large, you would a...

12 días ago | 0

Answered

What is the Aerospace Blockset quaternion convention?

See also the Answer in this post: https://www.mathworks.com/matlabcentral/answers/465053-rotation-order-of-quatrotate

What is the Aerospace Blockset quaternion convention?

See also the Answer in this post: https://www.mathworks.com/matlabcentral/answers/465053-rotation-order-of-quatrotate

13 días ago | 0

Answered

angle between three points (in 3D)?

See the discussion in these links: https://www.mathworks.com/matlabcentral/answers/101590-how-can-i-determine-the-angle-between...

angle between three points (in 3D)?

See the discussion in these links: https://www.mathworks.com/matlabcentral/answers/101590-how-can-i-determine-the-angle-between...

13 días ago | 0

Answered

How to convert char to uint8 and vice versa without changing the underlying data

Simply: c = original char array u = uint8(c); Or u = original uint8 array c = char(u); If you mean you want to reinterpret...

How to convert char to uint8 and vice versa without changing the underlying data

Simply: c = original char array u = uint8(c); Or u = original uint8 array c = char(u); If you mean you want to reinterpret...

15 días ago | 0

Answered

Multiplying each column of a matrix with a specific value

mat=[2,1,0,0;1,0,0,0;0,0,0,1]; % 2D matrix f = [25,5,10,1]; % row vector result = f .* mat; % element-wise multiply with virtu...

Multiplying each column of a matrix with a specific value

mat=[2,1,0,0;1,0,0,0;0,0,0,1]; % 2D matrix f = [25,5,10,1]; % row vector result = f .* mat; % element-wise multiply with virtu...

15 días ago | 0

| accepted

Answered

Creating Unit vectors in a loop

Since a complete answer has already been posted, I will post this one using a cell array result which will be much easier to ind...

Creating Unit vectors in a loop

Since a complete answer has already been posted, I will post this one using a cell array result which will be much easier to ind...

16 días ago | 1

Answered

When i run this code i get error using dec2bin (too many input arguments).

MATLAB is case sensitive. Text (uppercase T) is different from text (lowercase t). In the future, please post the complete erro...

When i run this code i get error using dec2bin (too many input arguments).

MATLAB is case sensitive. Text (uppercase T) is different from text (lowercase t). In the future, please post the complete erro...

16 días ago | 0

Answered

Maclauren Series Iteration. Answer provided just having trouble getting code to run properly

Some issues: 1) This line: new_cos=(old_cos-(x^n))/(factorial(n)); You are dividing the old_cos by the factorial(n). This do...

Maclauren Series Iteration. Answer provided just having trouble getting code to run properly

Some issues: 1) This line: new_cos=(old_cos-(x^n))/(factorial(n)); You are dividing the old_cos by the factorial(n). This do...

16 días ago | 1

| accepted