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

Answered

Solve the system of equations using Cramer's Rule x+y+z=9,2x+5y+7z=52,.2x+y-z=0.

Original question: Solve the system of equations using Cramer's Rule x+y+z=9,2x+5y+7z=52,.2x+y-z=0. i want code for it And ...

Solve the system of equations using Cramer's Rule x+y+z=9,2x+5y+7z=52,.2x+y-z=0.

Original question: Solve the system of equations using Cramer's Rule x+y+z=9,2x+5y+7z=52,.2x+y-z=0. i want code for it And ...

2 jours ago | 0

| accepted

Answered

How to transpose a cell array blockwise?

E.g., brute force approach result = reshape([D{1};D{2};D{3}],[],1);

How to transpose a cell array blockwise?

E.g., brute force approach result = reshape([D{1};D{2};D{3}],[],1);

2 jours ago | 1

| accepted

Answered

Classical orbital elements Vectors

Use the norm( ) function instead of mag( ). E.g., norm(v) instead of mag(v). Calculate evec before you calculate e. Your evec...

Classical orbital elements Vectors

Use the norm( ) function instead of mag( ). E.g., norm(v) instead of mag(v). Calculate evec before you calculate e. Your evec...

3 jours ago | 0

| accepted

Answered

Why `mxGetField` could not be assigned to output of c mex?

The reason this crashes is because you have created a copy of an mxArray variable without telling the MATLAB Memory Manager that...

Why `mxGetField` could not be assigned to output of c mex?

The reason this crashes is because you have created a copy of an mxArray variable without telling the MATLAB Memory Manager that...

5 jours ago | 0

| accepted

Answered

Replace the diagonal with NaN in this 5x5 matrix

You could use linear indexing for the diagonal. E.g., assuming x is square you could add this line to your function: y(1:size(...

Replace the diagonal with NaN in this 5x5 matrix

You could use linear indexing for the diagonal. E.g., assuming x is square you could add this line to your function: y(1:size(...

5 jours ago | 2

Answered

precision problem ? why ans for 10 ^ 5 * 0.0633 is 6.3299e+03

Normal floating point arithmetic effects. See this link: https://www.mathworks.com/matlabcentral/answers/57444-faq-why-is-0-3-...

precision problem ? why ans for 10 ^ 5 * 0.0633 is 6.3299e+03

Normal floating point arithmetic effects. See this link: https://www.mathworks.com/matlabcentral/answers/57444-faq-why-is-0-3-...

8 jours ago | 0

Answered

Getting a random list of numbers on a very specific interval

Generate the list according to the range width of valid values, then adjust the results. E.g., r = rand(10000,1)*80; ix = r >...

Getting a random list of numbers on a very specific interval

Generate the list according to the range width of valid values, then adjust the results. E.g., r = rand(10000,1)*80; ix = r >...

8 jours ago | 0

| accepted

Answered

error using multiplication, incorrect dimensions

There are vectors in those equations, so maybe you just need to use element-wise operations: k1 = ((b.*(p+theta-n2).*c0+I.*(a.*...

error using multiplication, incorrect dimensions

There are vectors in those equations, so maybe you just need to use element-wise operations: k1 = ((b.*(p+theta-n2).*c0+I.*(a.*...

8 jours ago | 0

Answered

Numeric integration for systems of vector equations

I haven't looked through your code, but from your description it sounds like you are making a fundamental error in your state sp...

Numeric integration for systems of vector equations

I haven't looked through your code, but from your description it sounds like you are making a fundamental error in your state sp...

8 jours ago | 0

| accepted

Answered

Preserving numerical symmetry in large nxn matrix

Here is a mex routine to do this calculation. It relies on inputting the diagonal matrix as a full vector of the diagonal eleme...

Preserving numerical symmetry in large nxn matrix

Here is a mex routine to do this calculation. It relies on inputting the diagonal matrix as a full vector of the diagonal eleme...

9 jours ago | 0

| accepted

Answered

Fast matrix multiplication with diagonal matrices

Here is a mex routine to do this calculation. It relies on inputting the diagonal matrices as full vectors of the diagonal elem...

Fast matrix multiplication with diagonal matrices

Here is a mex routine to do this calculation. It relies on inputting the diagonal matrices as full vectors of the diagonal elem...

9 jours ago | 1

| accepted

Answered

How to divide a vector randomly in 3 groups?

Based on my current understanding, maybe this rejection method might do what you want. Again, since there are only three groups...

How to divide a vector randomly in 3 groups?

Based on my current understanding, maybe this rejection method might do what you want. Again, since there are only three groups...

10 jours ago | 1

| accepted

Answered

Inverse a cell of matrices

Yes, you can do something like this: T1inv = cellfun(@inv,T1,'uni',false); That being said, this begs the question of what you...

Inverse a cell of matrices

Yes, you can do something like this: T1inv = cellfun(@inv,T1,'uni',false); That being said, this begs the question of what you...

10 jours ago | 0

Answered

Sorting two simple matrices

Use the 2nd output argument of the sort( ) function, which has the indexing. E.g., [Asorted,ix] = sort(A); Bsorted = B(ix);

Sorting two simple matrices

Use the 2nd output argument of the sort( ) function, which has the indexing. E.g., [Asorted,ix] = sort(A); Bsorted = B(ix);

10 jours ago | 1

| accepted

Answered

Preserving numerical symmetry in large nxn matrix

Why do you think L should be symmetric? E.g., (1) L = D^-1 * W * D (2) L^T = (D^-1 * W * D)^T = D^T * W^T * (D^-1)^T = D * W ...

Preserving numerical symmetry in large nxn matrix

Why do you think L should be symmetric? E.g., (1) L = D^-1 * W * D (2) L^T = (D^-1 * W * D)^T = D^T * W^T * (D^-1)^T = D * W ...

10 jours ago | 0

Answered

Error in ODE45, must return a column vector

Just make your function handle return a column vector by using ; instead of , to separate the elements. E.g., ode = @(Qhat,X) [...

Error in ODE45, must return a column vector

Just make your function handle return a column vector by using ; instead of , to separate the elements. E.g., ode = @(Qhat,X) [...

10 jours ago | 0

Answered

How to Solve 13 ODEs simultaneously by ode45

Your c0 has only 12 elements. It needs to have 13 elements.

How to Solve 13 ODEs simultaneously by ode45

Your c0 has only 12 elements. It needs to have 13 elements.

10 jours ago | 0

Answered

How to generate double pendulum using ode 45

You have a 4-element state vector, so your derivative needs to be a 4-element state vector. E.g., dxdt=[theta1dot;theta2dot;th...

How to generate double pendulum using ode 45

You have a 4-element state vector, so your derivative needs to be a 4-element state vector. E.g., dxdt=[theta1dot;theta2dot;th...

11 jours ago | 0

Answered

Help with arrays please

I'm not sure what the question is. Just enter the text as shown to create the 2x2 matrix A: A = [-10 -9; -8 6]; ...

Help with arrays please

I'm not sure what the question is. Just enter the text as shown to create the 2x2 matrix A: A = [-10 -9; -8 6]; ...

11 jours ago | 0

Answered

How to calculate mean to an equal area in Matlab?

n = 3; % or whatever number of samples you need, must be divisible into size of data time_average = mean(reshape(time_data,n,[]...

How to calculate mean to an equal area in Matlab?

n = 3; % or whatever number of samples you need, must be divisible into size of data time_average = mean(reshape(time_data,n,[]...

11 jours ago | 0

| accepted

Answered

What code should I use to be able to solve these MatLab questions?

Hint #1: Here is sample syntax to use to create a 2x4 matrix Q = [1 2 3 4; 5 6 7 8] Hint #2: See the following function for s...

What code should I use to be able to solve these MatLab questions?

Hint #1: Here is sample syntax to use to create a 2x4 matrix Q = [1 2 3 4; 5 6 7 8] Hint #2: See the following function for s...

11 jours ago | 0

Answered

How to divide a vector randomly in 3 groups?

Maybe a simple loop: n = numel(A); n10 = floor(0.10*n)-1; n80 = floor(0.80*n); for k=1:3 k1 = randi(n-n10); k2 = k...

How to divide a vector randomly in 3 groups?

Maybe a simple loop: n = numel(A); n10 = floor(0.10*n)-1; n80 = floor(0.80*n); for k=1:3 k1 = randi(n-n10); k2 = k...

14 jours ago | 0

Answered

Replacing for loops with vectorization

No, in general you cannot vectorize loops such as this. What you are doing in this particular loop is solving a 2nd order diffe...

Replacing for loops with vectorization

No, in general you cannot vectorize loops such as this. What you are doing in this particular loop is solving a 2nd order diffe...

14 jours ago | 1

| accepted

Answered

changing loop index within the loop

If you need to modify the loop index within the loop, use a while-loop instead of a for-loop.

changing loop index within the loop

If you need to modify the loop index within the loop, use a while-loop instead of a for-loop.

14 jours ago | 0

| accepted

Answered

Matrix Multiplication & Splitting

Based on your latest posts, it sounds like you really want A*C(3x3 slice)*B. So again it would be nice to do all the multiplies...

Matrix Multiplication & Splitting

Based on your latest posts, it sounds like you really want A*C(3x3 slice)*B. So again it would be nice to do all the multiplies...

14 jours ago | 2

Answered

Matrix Multiplication & Splitting

Your dimensions don't work. A*B is going to be 3x1. You can't multiply this by a 3xN matrix. That being said, suppose you did ...

Matrix Multiplication & Splitting

Your dimensions don't work. A*B is going to be 3x1. You can't multiply this by a 3xN matrix. That being said, suppose you did ...

14 jours ago | 1

Answered

solving ordinary differential equation

Starting with this differential equation: m*d2xdt2 + a*(dxdt)^2 + k*x= F*cos(omega*t) The first step is to solve the equation ...

solving ordinary differential equation

Starting with this differential equation: m*d2xdt2 + a*(dxdt)^2 + k*x= F*cos(omega*t) The first step is to solve the equation ...

14 jours ago | 0

| accepted

Answered

How to extract the expression inside of a trig function?

You could write your own simple parser for this. E.g., code for finding stuff inside the first function in the line could be: Z...

How to extract the expression inside of a trig function?

You could write your own simple parser for this. E.g., code for finding stuff inside the first function in the line could be: Z...

15 jours ago | 1

Answered

multi-indexing (slicing) with different slice size

You would probably need to generate the linear/logical indexes of the elements involved and then you could assign all of those s...

multi-indexing (slicing) with different slice size

You would probably need to generate the linear/logical indexes of the elements involved and then you could assign all of those s...

15 jours ago | 0

Answered

Trapezoid algorithm on an ODE

You need to pass the entire state to the derivative function, not just one element of the state. E.g., utmp = u(idx,:) + dt*dud...

Trapezoid algorithm on an ODE

You need to pass the entire state to the derivative function, not just one element of the state. E.g., utmp = u(idx,:) + dt*dud...

16 jours ago | 1

| accepted