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

Answered

Plot x^2+y^2=4

E.g., since you know it is a circle with radius 2 centered at the origin; ang = 0:0.01:2*pi; x = 2*cos(ang); y = 2*sin(ang); ...

Plot x^2+y^2=4

E.g., since you know it is a circle with radius 2 centered at the origin; ang = 0:0.01:2*pi; x = 2*cos(ang); y = 2*sin(ang); ...

1 hour ago | 0

Answered

Matrix n x n with n is integer

Examples, If N is a 5x7 matrix and n is 3, then your function would return N(1:3,5:7), the 3x3 sub-matrix at the top right cor...

Matrix n x n with n is integer

Examples, If N is a 5x7 matrix and n is 3, then your function would return N(1:3,5:7), the 3x3 sub-matrix at the top right cor...

2 hours ago | 0

Answered

How to solve a second order differential equations with matrices by using "ODE45"?

1/m is a scalar/3x3 hence the error. Normally I would advise backslash here, but that brings up another issue. If M, C, and K ...

How to solve a second order differential equations with matrices by using "ODE45"?

1/m is a scalar/3x3 hence the error. Normally I would advise backslash here, but that brings up another issue. If M, C, and K ...

1 day ago | 2

Answered

Image read in MATLAB and C

An int is likely 4 bytes on your machine, not 2 bytes. Also the expression "order" by itself evaluates as a pointer to the firs...

Image read in MATLAB and C

An int is likely 4 bytes on your machine, not 2 bytes. Also the expression "order" by itself evaluates as a pointer to the firs...

5 days ago | 0

Answered

Appending a row vector into a matrix based on given conditions

x = abs(b-60) > abs(b-550); % fixed typo xzplane550 = equakemat(x,:); xzplane60 = equakemat(~x,:); If all the data ends up in...

Appending a row vector into a matrix based on given conditions

x = abs(b-60) > abs(b-550); % fixed typo xzplane550 = equakemat(x,:); xzplane60 = equakemat(~x,:); If all the data ends up in...

6 days ago | 0

| accepted

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...

6 days 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...

7 days 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...

7 days 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...

8 days 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...

9 days 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...

9 days 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)...

10 days 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,...

10 days 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...

12 days 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;

12 days 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 ...

13 days 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)

14 days 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...

14 days 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...

15 days 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)

15 days 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,:);

15 days 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) +...

15 days 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...

15 days 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...

15 days 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.

15 days 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 ...

15 days 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...

16 days 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...

18 days 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

19 days 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...

19 days ago | 0