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

Answered

"Matrix Dimensions must agree"

t is used to build r, but it is not the same length as phi.

"Matrix Dimensions must agree"

t is used to build r, but it is not the same length as phi.

environ 13 heures ago | 1

| accepted

Answered

How to create a periodic function?

Not sure what you mean by "repeated at [2,10]". Maybe this: y = mod(x,2); ix = y > 1; y(ix) = 2 - y(ix);

How to create a periodic function?

Not sure what you mean by "repeated at [2,10]". Maybe this: y = mod(x,2); ix = y > 1; y(ix) = 2 - y(ix);

1 jour ago | 0

| accepted

Answered

How do i use output of one function as input to the other ?

You can do this at the point where you are calling the function neg. E.g., z = neg(pos(x,y),q);

How do i use output of one function as input to the other ?

You can do this at the point where you are calling the function neg. E.g., z = neg(pos(x,y),q);

1 jour ago | 0

Answered

Index in position 1 is invalid. Array indices must be positive integers or logical values.

When i=m in your loop you try to access kernel(m-m,n-j) which is kernel(0,m-j), and 0 is an invalid index. Similar problems wit...

Index in position 1 is invalid. Array indices must be positive integers or logical values.

When i=m in your loop you try to access kernel(m-m,n-j) which is kernel(0,m-j), and 0 is an invalid index. Similar problems wit...

1 jour ago | 0

| accepted

Answered

Solve a differential equation system with 4th order Runge-Kutta method with three equations

Not sure if you actually use t in your derivative functions, but you are missing that input from your j1, k1, and l1 code: ...

Solve a differential equation system with 4th order Runge-Kutta method with three equations

Not sure if you actually use t in your derivative functions, but you are missing that input from your j1, k1, and l1 code: ...

1 jour ago | 0

Answered

sum of cubes question

This homework question is poorly written: It seems like the intent of the n is to use it as the upper limit of the for-loop, bu...

sum of cubes question

This homework question is poorly written: It seems like the intent of the n is to use it as the upper limit of the for-loop, bu...

1 jour ago | 1

| accepted

Answered

Calling a function from another function

my_first_function1( ) doesn't return any value to the caller. To return a value you use this syntax: function absx = my_first_...

Calling a function from another function

my_first_function1( ) doesn't return any value to the caller. To return a value you use this syntax: function absx = my_first_...

2 jours ago | 1

| accepted

Answered

Numerical integration of the differential equation of motion of the two body problem

Your biggest problem is that you don't carry enough states in your derivative function. Your ODE is a 3D 2nd order equation, so...

Numerical integration of the differential equation of motion of the two body problem

Your biggest problem is that you don't carry enough states in your derivative function. Your ODE is a 3D 2nd order equation, so...

2 jours ago | 0

| accepted

Answered

How to swap multiple rows of a matrix at a time

A = your matrix A([1:63,142:202],:) = A([142:202,1:63],:);

How to swap multiple rows of a matrix at a time

A = your matrix A([1:63,142:202],:) = A([142:202,1:63],:);

3 jours ago | 0

| accepted

Answered

Probability of binary sequence with Monte Carlo

First point is that probability of stopping at n=3 is not 2/6, it is (3/4)*(2/6) because you have to include the probablility th...

Probability of binary sequence with Monte Carlo

First point is that probability of stopping at n=3 is not 2/6, it is (3/4)*(2/6) because you have to include the probablility th...

6 jours ago | 1

| accepted

Answered

Problem at +/- 180 degrees in orientation estimation from IMU data

You can try the unwrap( ) function: https://www.mathworks.com/help/matlab/ref/unwrap.html

Problem at +/- 180 degrees in orientation estimation from IMU data

You can try the unwrap( ) function: https://www.mathworks.com/help/matlab/ref/unwrap.html

6 jours ago | 0

| accepted

Answered

Help with secant method

You might look here which even includes example code: https://en.wikipedia.org/wiki/Secant_method

Help with secant method

You might look here which even includes example code: https://en.wikipedia.org/wiki/Secant_method

6 jours ago | 0

Answered

How do I add an integer to every or any nth row

A(k,:) is the k'th row of A A(:,k) is the k'th column of A A([k m p],:) is the sub-matrix formed from the k'th, m'th, and p'th...

How do I add an integer to every or any nth row

A(k,:) is the k'th row of A A(:,k) is the k'th column of A A([k m p],:) is the sub-matrix formed from the k'th, m'th, and p'th...

6 jours ago | 1

| accepted

Answered

First and last occurrence of an element in an array

So the description of the problem doesn't say anything about consecutive values, so the code you have for that should be elimina...

First and last occurrence of an element in an array

So the description of the problem doesn't say anything about consecutive values, so the code you have for that should be elimina...

6 jours ago | 0

| accepted

Answered

Parse error at ']'

Looks like you just need commas instead of periods. E.g., [r,i,v,dr,di,dv]

Parse error at ']'

Looks like you just need commas instead of periods. E.g., [r,i,v,dr,di,dv]

7 jours ago | 0

Answered

Simple Blackjack Simulation in MATLAB

A few things ... Seems like you should have this: deck = repmat([1,2,3,4,5,6,7,8,9,10,10,10,10],1,8); % two decks worth of car...

Simple Blackjack Simulation in MATLAB

A few things ... Seems like you should have this: deck = repmat([1,2,3,4,5,6,7,8,9,10,10,10,10],1,8); % two decks worth of car...

7 jours ago | 0

Answered

Can not convert USHORT MAX to ufix16_Sp01

If you have a slope scaling of 0.01 and a bias of 0, doesn't that mean the max value is 65535*0.01 = 655.35?

Can not convert USHORT MAX to ufix16_Sp01

If you have a slope scaling of 0.01 and a bias of 0, doesn't that mean the max value is 65535*0.01 = 655.35?

7 jours ago | 0

| accepted

Answered

Using ODE45 for coupled equations

General procedure: Define a variable, let's call it y to match the doc, that will be your state vector. Each element of y corr...

Using ODE45 for coupled equations

General procedure: Define a variable, let's call it y to match the doc, that will be your state vector. Each element of y corr...

7 jours ago | 0

| accepted

Answered

please help with work

Use the input( ) function to get the user input. Use the optional 's' argument to get the input as a char string. I'm assuming...

please help with work

Use the input( ) function to get the user input. Use the optional 's' argument to get the input as a char string. I'm assuming...

7 jours ago | 0

Answered

How to get Matlab Version at Mex Compilation Time?

My MATLAB version code works for me in R2020a: >> mex matlab_version_test.c Building with 'Microsoft Visual C++ 2015 (C)'. ME...

How to get Matlab Version at Mex Compilation Time?

My MATLAB version code works for me in R2020a: >> mex matlab_version_test.c Building with 'Microsoft Visual C++ 2015 (C)'. ME...

7 jours ago | 0

| accepted

Answered

Is there a way to use symbolic functions in ode45

Convert it to a function handle so that it can be used with numeric inputs. E.g., >> syms x >> f(x) = sqrt(x) + 2 f(x) = x^...

Is there a way to use symbolic functions in ode45

Convert it to a function handle so that it can be used with numeric inputs. E.g., >> syms x >> f(x) = sqrt(x) + 2 f(x) = x^...

7 jours ago | 1

| accepted

Answered

how to write matlab code for physics problem?

You do not explicitly state that acceleration is constant, but I assume that is the case. The equations then are simply vf = v...

how to write matlab code for physics problem?

You do not explicitly state that acceleration is constant, but I assume that is the case. The equations then are simply vf = v...

7 jours ago | 0

Answered

I need help for calculating mortgage for a homework problem

OK, so ask yourself what has to happen every month? You get charged interest and you make a payment, right? And you are told t...

I need help for calculating mortgage for a homework problem

OK, so ask yourself what has to happen every month? You get charged interest and you make a payment, right? And you are told t...

8 jours ago | 0

Answered

forward euler for a system of equations

I'm assuming this for j=1:t1:dt was meant to be something like this for j=1:t1/dt

forward euler for a system of equations

I'm assuming this for j=1:t1:dt was meant to be something like this for j=1:t1/dt

8 jours ago | 0

Answered

Splitting a vector into a matrix

result = [x(1:2:end) x(2:2:end)]; or result = reshape(x,2,[]).';

Splitting a vector into a matrix

result = [x(1:2:end) x(2:2:end)]; or result = reshape(x,2,[]).';

8 jours ago | 1

| accepted

Answered

Mex file c. Getting different results from matlab

MATLAB stores matrices in column order. E.g., if A is a 2x3 matrix, and p is a pointer to the data area of A in a mex routine, ...

Mex file c. Getting different results from matlab

MATLAB stores matrices in column order. E.g., if A is a 2x3 matrix, and p is a pointer to the data area of A in a mex routine, ...

9 jours ago | 0

| accepted

Answered

I don't know how to prove sin^2(x)+cos^2(x)=1

[cos(x),sin(x)] is defined to be a point on the unit circle, so by definition we have sin^2(x) + cos^2(x) = 1 always. This isn'...

I don't know how to prove sin^2(x)+cos^2(x)=1

[cos(x),sin(x)] is defined to be a point on the unit circle, so by definition we have sin^2(x) + cos^2(x) = 1 always. This isn'...

9 jours ago | 0

Answered

Using loops in matrix

So your latest post is a really good effort! A couple of things you are missing from the instructions: "create a new variable ...

Using loops in matrix

So your latest post is a really good effort! A couple of things you are missing from the instructions: "create a new variable ...

9 jours ago | 1

Answered

How do I use function for a function which has a matrix with variable index?

You don't have a branch for the AR>Max case. If you hit that condition, the output variables will not be assigned. Also, ContA...

How do I use function for a function which has a matrix with variable index?

You don't have a branch for the AR>Max case. If you hit that condition, the output variables will not be assigned. Also, ContA...

9 jours ago | 0

Answered

I do not know why am I getting imaginary numbers.

Look at the following for the values of i you are using: log(1-i) E.g., >> log(-1) ans = 0.0000 + 3.1416i

I do not know why am I getting imaginary numbers.

Look at the following for the values of i you are using: log(1-i) E.g., >> log(-1) ans = 0.0000 + 3.1416i

10 jours ago | 0

| accepted