Networker, learner, educator

Professional Interests: Spacecraft dynamics and control, numerical analysis, simulation, animation

Answered

Do while loop in Matlab

There is no 1-to-1 correspondence to the C++ do while loop in MATLAB. Your best option is to use a while loop. The difference is...

Do while loop in Matlab

There is no 1-to-1 correspondence to the C++ do while loop in MATLAB. Your best option is to use a while loop. The difference is...

10 months ago | 6

| accepted

Answered

Splitting a matrix into submatrices by value

Something like this? A = [2 3 0 3;... 3 2 1 3;... 2 2 1 2] A = 2 3 0 3 3 2 ...

Splitting a matrix into submatrices by value

Something like this? A = [2 3 0 3;... 3 2 1 3;... 2 2 1 2] A = 2 3 0 3 3 2 ...

11 months ago | 1

| accepted

Answered

How can I solve this transcendental equation graphically?

Timaway, define a vector |Xi|, e.g. using the |linspace| command. Then plot |tan(Xi)| and the right side of your equation into t...

How can I solve this transcendental equation graphically?

Timaway, define a vector |Xi|, e.g. using the |linspace| command. Then plot |tan(Xi)| and the right side of your equation into t...

12 months ago | 0

| accepted

Answered

Converting Matlab code and graphs into Latex

Hi Muhammad, there are a couple of packages on File Exchange, e.g. <https://de.mathworks.com/matlabcentral/fileexchange/8015-m-c...

Converting Matlab code and graphs into Latex

Hi Muhammad, there are a couple of packages on File Exchange, e.g. <https://de.mathworks.com/matlabcentral/fileexchange/8015-m-c...

12 months ago | 0

Answered

solving a second order linear differential equation

Almost there: g = 9.8; l = 0.5; t_span = [0 30]; teta0 = deg2rad(60); tetad0 = 0; F = @(t,q) [q(2);-(g/l...

solving a second order linear differential equation

Almost there: g = 9.8; l = 0.5; t_span = [0 30]; teta0 = deg2rad(60); tetad0 = 0; F = @(t,q) [q(2);-(g/l...

12 months ago | 0

| accepted

Answered

how to plot the phase portraits of a onlinear dynamics of rock-paper-scissors game model

Hi Cui, there are two steps you need to take to get to your desired result: # Solve the differential equations (DE): Essentia...

how to plot the phase portraits of a onlinear dynamics of rock-paper-scissors game model

Hi Cui, there are two steps you need to take to get to your desired result: # Solve the differential equations (DE): Essentia...

1 year ago | 0

| accepted

Answered

matlab giving complex number when the expected answer is a real number?

Note: >> (-1)^1.5 ans = 0.0000 - 1.0000i which is not the same as >> -1^1.5 % = -(1^1.5) ans = -1

matlab giving complex number when the expected answer is a real number?

Note: >> (-1)^1.5 ans = 0.0000 - 1.0000i which is not the same as >> -1^1.5 % = -(1^1.5) ans = -1

1 year ago | 2

| accepted

Answered

Why don't i get a vector for phi1?

All constants need to be defined. Then use: t = pi/2:0.01:2*pi+(pi/2); phi1 = (a^2+a^2+d^2+2*a*d*cos(pi-t)-d^2)./(2*b*...

Why don't i get a vector for phi1?

All constants need to be defined. Then use: t = pi/2:0.01:2*pi+(pi/2); phi1 = (a^2+a^2+d^2+2*a*d*cos(pi-t)-d^2)./(2*b*...

1 year ago | 0

| accepted

Answered

How do I display individual values from an if statement in a messgae?

Hi Matthew, I assume you are using a loop to do the iterations, most likely a |while| loop. If you say you can print only all th...

How do I display individual values from an if statement in a messgae?

Hi Matthew, I assume you are using a loop to do the iterations, most likely a |while| loop. If you say you can print only all th...

1 year ago | 0

| accepted

Submitted

RLC circuit demo bundle

Analyze the RLC series circuit using different modeling approaches and with hardware

1 year ago | 10 downloads |

Answered

WHY do I get this error

mahesh, is the above code all in one and the same script? If it is modify like this: [t,y]= ode45(@free25,[0 10],[0 0.09]);%...

WHY do I get this error

mahesh, is the above code all in one and the same script? If it is modify like this: [t,y]= ode45(@free25,[0 10],[0 0.09]);%...

2 years ago | 0

| accepted

Answered

Error in Matlab Fundamentals, 6.1 Project Review

Adam, thanks for bringing this to our attention. I will forward your information internally and make sure it is addressed as...

Error in Matlab Fundamentals, 6.1 Project Review

Adam, thanks for bringing this to our attention. I will forward your information internally and make sure it is addressed as...

2 years ago | 0

Answered

How do I count how many iterations my root is in a smaller interval?

In each iteration you have two intervals, |[a,c]| and |[c,b]|. Compute the size of both intervals and use the last |if-else| con...

How do I count how many iterations my root is in a smaller interval?

In each iteration you have two intervals, |[a,c]| and |[c,b]|. Compute the size of both intervals and use the last |if-else| con...

2 years ago | 0

| accepted

Answered

i need to find variable x and the error is " Undefined function or variable 'x'. "

A couple of things. In the code you show |Ei| is not defined and it looks like you need to solve the equation for different |a|....

i need to find variable x and the error is " Undefined function or variable 'x'. "

A couple of things. In the code you show |Ei| is not defined and it looks like you need to solve the equation for different |a|....

2 years ago | 1

| accepted

Answered

Help with error and coding.

One thing I noticed is the following: in your second while-loop you have while k<=24 x_c(k+1)=dist(k)*cosd(hr_deg(de...

Help with error and coding.

One thing I noticed is the following: in your second while-loop you have while k<=24 x_c(k+1)=dist(k)*cosd(hr_deg(de...

2 years ago | 0

Answered

Function Generation Error (Not enough input arguments)

Store the function in a file called |deneme.m| and then execute in the MATLAB command window y = deneme(3)

Function Generation Error (Not enough input arguments)

Store the function in a file called |deneme.m| and then execute in the MATLAB command window y = deneme(3)

2 years ago | 0

| accepted

Answered

Error RungeKutta method......not enough input arguments

Store |runKut4| and |fex7_4| in separate m-files and then execute [x,y] = runKut4(@fex7_4,0,[0 1],2,0.25); e.g. in the MA...

Error RungeKutta method......not enough input arguments

Store |runKut4| and |fex7_4| in separate m-files and then execute [x,y] = runKut4(@fex7_4,0,[0 1],2,0.25); e.g. in the MA...

2 years ago | 0

| accepted

Answered

How do I insert a column with zeros in the second column of a mxn matrix?

Brute force: A = [1 2 3; 4 5 6; 7 8 9] A = [zeros(size(A,1),1) A]; A(:,[1 2]) = A(:,[2 1])

How do I insert a column with zeros in the second column of a mxn matrix?

Brute force: A = [1 2 3; 4 5 6; 7 8 9] A = [zeros(size(A,1),1) A]; A(:,[1 2]) = A(:,[2 1])

2 years ago | 0

| accepted

Answered

Is it possible that we can save .m file results with different name each time of execution?

@km, take a look at the documentation <https://www.mathworks.com/help/matlab/import_export/writing-to-text-data-files-with-low-l...

Is it possible that we can save .m file results with different name each time of execution?

@km, take a look at the documentation <https://www.mathworks.com/help/matlab/import_export/writing-to-text-data-files-with-low-l...

2 years ago | 0

Answered

Plot multiple subintervals in one figure

Joakim, is this what you had in mind? f=@(t,u)-u+sin(5*t)+cos(2*t); a=0; b=5; ua=2; % begynnelsevillkor t=linspace(...

Plot multiple subintervals in one figure

Joakim, is this what you had in mind? f=@(t,u)-u+sin(5*t)+cos(2*t); a=0; b=5; ua=2; % begynnelsevillkor t=linspace(...

2 years ago | 0

| accepted

Answered

eval([ans '=' num2str(x0(i)) ';']); gives an error "The expression to the left of the equals sign is not a valid target for an assignment". what could be the problem?

Just wondering if the following would do the trick... eval('ans = num2str(x0(i));')

eval([ans '=' num2str(x0(i)) ';']); gives an error "The expression to the left of the equals sign is not a valid target for an assignment". what could be the problem?

Just wondering if the following would do the trick... eval('ans = num2str(x0(i));')

2 years ago | 0

Answered

Is there a way to solve a system of ordinary differential equation with different time scale by using ode solver?

Ram, it sounds like you are referring to solving (possibly) stiff ODE. If you do, yes, there are solvers. See the <https://www.m...

Is there a way to solve a system of ordinary differential equation with different time scale by using ode solver?

Ram, it sounds like you are referring to solving (possibly) stiff ODE. If you do, yes, there are solvers. See the <https://www.m...

2 years ago | 0

Answered

how to find min or max value in each row of a matrix and its index, if a matrix is 3x2 it will find the min in first row

Use [val,loc] = min(R') val = 21 35 42 % min value in each row loc = 3 1 1 % column locati...

how to find min or max value in each row of a matrix and its index, if a matrix is 3x2 it will find the min in first row

Use [val,loc] = min(R') val = 21 35 42 % min value in each row loc = 3 1 1 % column locati...

2 years ago | 3

| accepted

Answered

Multiplication between 2 matrix

Danilo, use the Symbolic Math Toolbox syms B C a b c d A = [1 0; 2 3]; B = [a b; c d]; C = A*B C = [ a, ...

Multiplication between 2 matrix

Danilo, use the Symbolic Math Toolbox syms B C a b c d A = [1 0; 2 3]; B = [a b; c d]; C = A*B C = [ a, ...

2 years ago | 0

| accepted

Answered

Can't figure out what's wrong with my code

Kevin, I see two problems with your algorithm/function |f(x)|: if f(xr)*f(xl)>0 needs to be if f(xr)*f(xl)<0 and ...

Can't figure out what's wrong with my code

Kevin, I see two problems with your algorithm/function |f(x)|: if f(xr)*f(xl)>0 needs to be if f(xr)*f(xl)<0 and ...

2 years ago | 0

Answered

VR Sink Parameter selection

Omar, you need to rename the |(Transform)| before you can access (that is, check the boxes of) the properties. You can do thi...

VR Sink Parameter selection

Omar, you need to rename the |(Transform)| before you can access (that is, check the boxes of) the properties. You can do thi...

2 years ago | 0

| accepted

Answered

Help with splitting a string into a character array.

You could use s = 'Potato'; t = num2cell(s) t = 1×6 cell array {'P'} {'o'} {'t'} {'a'} {'t'} ...

Help with splitting a string into a character array.

You could use s = 'Potato'; t = num2cell(s) t = 1×6 cell array {'P'} {'o'} {'t'} {'a'} {'t'} ...

2 years ago | 1

| accepted

Answered

Code returns, "Error using quiver3 (line 44) V and W must be the same size." How to fix this? The variables are the same size(1x25 double).

Aamna, based on your information I am not clear exactly what you want to do. However, the input arguments for coordinates and ve...

Code returns, "Error using quiver3 (line 44) V and W must be the same size." How to fix this? The variables are the same size(1x25 double).

Aamna, based on your information I am not clear exactly what you want to do. However, the input arguments for coordinates and ve...

2 years ago | 0

Answered

From Scientific Calculator [Solve] to matlab

Alex, use something like fun = @(X) cos(X)^2*cos(3*X)^2 - 0.5; options = optimoptions('fsolve','Display','none','PlotFcn',...

From Scientific Calculator [Solve] to matlab

Alex, use something like fun = @(X) cos(X)^2*cos(3*X)^2 - 0.5; options = optimoptions('fsolve','Display','none','PlotFcn',...

2 years ago | 0