Answered

Problem with fplot function - displays grey zone instead of functions

Change all the ^ to .^ (i.e. dot^)and the * to .*

Problem with fplot function - displays grey zone instead of functions

Change all the ^ to .^ (i.e. dot^)and the * to .*

alrededor de 1 mes ago | 1

Answered

I would like to create a handle function by for loop in matlab, but it does not work. I will be thankful if some body help me.

More like this? sfn = @(x,a,b) (a - b)*x; a=[1 2 3]; b=[4 5 6]; n=length(a); x = 1; % specify whatever x value you want f...

I would like to create a handle function by for loop in matlab, but it does not work. I will be thankful if some body help me.

More like this? sfn = @(x,a,b) (a - b)*x; a=[1 2 3]; b=[4 5 6]; n=length(a); x = 1; % specify whatever x value you want f...

alrededor de 1 mes ago | 0

Answered

How to solve this implicit equation in matlab?

Good idea to plot a graph first, to see roughly where the root lies. Then use fzero. For example:: fn = @(x)log((0.77*x-0.77)...

How to solve this implicit equation in matlab?

Good idea to plot a graph first, to see roughly where the root lies. Then use fzero. For example:: fn = @(x)log((0.77*x-0.77)...

alrededor de 1 mes ago | 0

Answered

Problem with solving discrete element method using leap frog method

The following gets the code working, but I've no idea if the results are meaningful!! n_part=4; kn=5; kt=2/7*kn; m=0.3; g=9...

Problem with solving discrete element method using leap frog method

The following gets the code working, but I've no idea if the results are meaningful!! n_part=4; kn=5; kt=2/7*kn; m=0.3; g=9...

alrededor de 1 mes ago | 0

| accepted

Answered

Write a loop to plot a model graph

A little more like this. You need a smaller value of dv and a while loop. The fit isn't very good! %% Observed Wave dispersi...

Write a loop to plot a model graph

A little more like this. You need a smaller value of dv and a while loop. The fit isn't very good! %% Observed Wave dispersi...

alrededor de 1 mes ago | 0

| accepted

Answered

Making a line thought points plotted from for loop in MATLAB

Like this? R1= 1399.580e+6; C1= 374.868e-6; R2= 1497.005e+6; C2= 350.472e-6; R3= 19573.407e+6; C3= 2429.373e-12;...

Making a line thought points plotted from for loop in MATLAB

Like this? R1= 1399.580e+6; C1= 374.868e-6; R2= 1497.005e+6; C2= 350.472e-6; R3= 19573.407e+6; C3= 2429.373e-12;...

alrededor de 1 mes ago | 0

| accepted

Answered

How do I plot and return the values of multiple intersections between a function and zero?

Here's one possibility (though you get repeated results for the roots!): det_a = @(x) sin(x).*cosh(x) - cos(x).*sinh(x); x=0:1...

How do I plot and return the values of multiple intersections between a function and zero?

Here's one possibility (though you get repeated results for the roots!): det_a = @(x) sin(x).*cosh(x) - cos(x).*sinh(x); x=0:1...

alrededor de 1 mes ago | 0

| accepted

Answered

Simplify Matrix decimal to integers

One way is M = [881/2158 985/1393 780/1351 881/2158 -985/1393 780/1351 -881/1079 ...

Simplify Matrix decimal to integers

One way is M = [881/2158 985/1393 780/1351 881/2158 -985/1393 780/1351 -881/1079 ...

alrededor de 1 mes ago | 0

Answered

Tring to solve for a transcendental equation

You can rearrange the equation as eigen*tan(eigen) = Bi and use fzero as below. However, because of the nature of tan, your res...

Tring to solve for a transcendental equation

You can rearrange the equation as eigen*tan(eigen) = Bi and use fzero as below. However, because of the nature of tan, your res...

alrededor de 1 mes ago | 0

| accepted

Answered

Question regarding MATLAB code to solve for electron in constant electric and magnetic field

If you are going to use global variables they need to be declared outside the function as well as inside. Your values of q and ...

Question regarding MATLAB code to solve for electron in constant electric and magnetic field

If you are going to use global variables they need to be declared outside the function as well as inside. Your values of q and ...

alrededor de 2 meses ago | 0

Answered

Hello, I am trying to plot the transmission coefficient vs energy for the double barrier potential, but I get an error. May I know what I have done wrong here?

See the following V_0 = 0.2800; % Barrier strength in eV hbar = 1.054571596e-34; % Reduced Planck constant m = 5.465629128e-3...

Hello, I am trying to plot the transmission coefficient vs energy for the double barrier potential, but I get an error. May I know what I have done wrong here?

See the following V_0 = 0.2800; % Barrier strength in eV hbar = 1.054571596e-34; % Reduced Planck constant m = 5.465629128e-3...

alrededor de 2 meses ago | 0

Answered

Simulation of point kinetics reactor equations

There are seven equations if you are using all six delayed neutron groups. You don't give your reactivity, nor the individual b...

Simulation of point kinetics reactor equations

There are seven equations if you are using all six delayed neutron groups. You don't give your reactivity, nor the individual b...

alrededor de 2 meses ago | 1

| accepted

Answered

calculating angle between line of best fit and x axis

Take the arctangent of the gradient of the straight line.

calculating angle between line of best fit and x axis

Take the arctangent of the gradient of the straight line.

alrededor de 2 meses ago | 0

Answered

deleting separate zeros from vector

Here's one way (there is probably a slicker way!): A = [ 0 0 1 0 0 0 1 0 1 0 0 1 5 9 8 2 0 3 0 1 0 0 0 ]; ...

deleting separate zeros from vector

Here's one way (there is probably a slicker way!): A = [ 0 0 1 0 0 0 1 0 1 0 0 1 5 9 8 2 0 3 0 1 0 0 0 ]; ...

alrededor de 2 meses ago | 0

Answered

Making a Euler Method script to solve for velocity but am encountering "Array indices must be positive integers or logical values" Error

Try changing your loop to for i=1:numel(t) %%% i loop not t f = (g - (D * p * A * v(i).^2)/(2*m)); %%% v(i) v(i+1) ...

Making a Euler Method script to solve for velocity but am encountering "Array indices must be positive integers or logical values" Error

Try changing your loop to for i=1:numel(t) %%% i loop not t f = (g - (D * p * A * v(i).^2)/(2*m)); %%% v(i) v(i+1) ...

alrededor de 2 meses ago | 0

Answered

Error solving for a particular variable from two equations

You could use fzero: TonTc = 0.01:0.01:0.99; a = zeros(1,numel(TonTc)); a0 = 1; % initial giuess for k = 1:numel(a) ...

Error solving for a particular variable from two equations

You could use fzero: TonTc = 0.01:0.01:0.99; a = zeros(1,numel(TonTc)); a0 = 1; % initial giuess for k = 1:numel(a) ...

alrededor de 2 meses ago | 0

| accepted

Answered

Replacing sym with function handle

Do you mean something like this? phi = pi/3; [nr, wr] = fn(phi); disp(phi) disp(nr(4)+56*3/2) disp(wr(4)) function [nr...

Replacing sym with function handle

Do you mean something like this? phi = pi/3; [nr, wr] = fn(phi); disp(phi) disp(nr(4)+56*3/2) disp(wr(4)) function [nr...

alrededor de 2 meses ago | 0

Answered

I'm trying to solve this system of ODE's describing a mechanical spring model.

Might be better to forget about symbolics, treat each 2nd order ode as two first order ode's and do the following: %applied for...

I'm trying to solve this system of ODE's describing a mechanical spring model.

Might be better to forget about symbolics, treat each 2nd order ode as two first order ode's and do the following: %applied for...

alrededor de 2 meses ago | 0

Answered

Solving a first order ODE with Euler backwards method

Your y_true is only valid for t>= 5 (smaller values give imaginary results for y). So, try going from 5 to 8: % y_true = log(t...

Solving a first order ODE with Euler backwards method

Your y_true is only valid for t>= 5 (smaller values give imaginary results for y). So, try going from 5 to 8: % y_true = log(t...

alrededor de 2 meses ago | 0

| accepted

Answered

Need help to create a loop

How about: e=2.7183; gamma=0.1333; k = [1,9,23,7,23,9,20,29,63,102,73,59,27,130,75,185,70,92,326]; Rt=0:0.01:10; P = zero...

Need help to create a loop

How about: e=2.7183; gamma=0.1333; k = [1,9,23,7,23,9,20,29,63,102,73,59,27,130,75,185,70,92,326]; Rt=0:0.01:10; P = zero...

alrededor de 2 meses ago | 1

Answered

Newton's method iterations

I suggest you plot a graph of your function, then you can see where good initial estimates would be. For example f = @(x) 2*ex...

Newton's method iterations

I suggest you plot a graph of your function, then you can see where good initial estimates would be. For example f = @(x) 2*ex...

alrededor de 2 meses ago | 0

Answered

the variable appears to change size every loop iteration

Answered here: https://uk.mathworks.com/matlabcentral/answers/1464024-the-variable-appears-to-change-size-every-loop-iteration?s...

the variable appears to change size every loop iteration

Answered here: https://uk.mathworks.com/matlabcentral/answers/1464024-the-variable-appears-to-change-size-every-loop-iteration?s...

2 meses ago | 1

Answered

Writing the dirac function as a function handle

Try dirac_i = @(x) x==i; % This assumes i has been fixed before the function is defined

Writing the dirac function as a function handle

Try dirac_i = @(x) x==i; % This assumes i has been fixed before the function is defined

2 meses ago | 0

| accepted

Answered

How to plot 2 graphs with input as a range and join them together?

Like this p0=0; p1=6; p2=1; p3=3; p4=3; t=[0:0.01:1]; x1 = (1/6)*[((((-t).^3)+(3*(t.^2))-(3*t)+1)*p0)+(((3*(t.^3))-(6*(t....

How to plot 2 graphs with input as a range and join them together?

Like this p0=0; p1=6; p2=1; p3=3; p4=3; t=[0:0.01:1]; x1 = (1/6)*[((((-t).^3)+(3*(t.^2))-(3*t)+1)*p0)+(((3*(t.^3))-(6*(t....

2 meses ago | 0

Answered

the variable appears to change size every loop iteration

You don't need the loop: If = [0 0.5 1.0 1.5 2.0 2.5]; Ea = [0 75 150 205 242 270]; Ra = 0.14; RI = 2; la = 100; Ifield = ...

the variable appears to change size every loop iteration

You don't need the loop: If = [0 0.5 1.0 1.5 2.0 2.5]; Ea = [0 75 150 205 242 270]; Ra = 0.14; RI = 2; la = 100; Ifield = ...

2 meses ago | 1

Answered

Unable to find solution to matrix using Gauss Seidal code. How should I proceed to get the solution?

You are dividing by A(i,i) some of which are zero. These will introduce NaNs.

Unable to find solution to matrix using Gauss Seidal code. How should I proceed to get the solution?

You are dividing by A(i,i) some of which are zero. These will introduce NaNs.

2 meses ago | 0

Answered

Solving Eqn with Varying Variable (Ms)

Like this: a1a4 = 1./[1, 2, 4, 10]; n = 10000; p4p1 = 1:n; M = zeros(numel(a1a4),n); for j = 1:numel(a1a4) m = 1.01; ...

Solving Eqn with Varying Variable (Ms)

Like this: a1a4 = 1./[1, 2, 4, 10]; n = 10000; p4p1 = 1:n; M = zeros(numel(a1a4),n); for j = 1:numel(a1a4) m = 1.01; ...

2 meses ago | 1

| accepted

Answered

To solve two 2nd order coupled differential equation using ODE45?

Replace each 2nd order ODE by two 1st order ODEs. e.g. set V1 = X1', V2 = X2', then V1' = (50*sin(f(t) - V1)*V2')/sin(f(t)), V...

To solve two 2nd order coupled differential equation using ODE45?

Replace each 2nd order ODE by two 1st order ODEs. e.g. set V1 = X1', V2 = X2', then V1' = (50*sin(f(t) - V1)*V2')/sin(f(t)), V...

2 meses ago | 0

| accepted

Answered

Using Ode45 to solve dynamics problem (ISA model)

Like this z0 = 39045; %const.h0; v0 = 0; %const.v0; t0 = 0; tf = 800; N = 60000; tspan = linspace(t0, tf, N); X ...

Using Ode45 to solve dynamics problem (ISA model)

Like this z0 = 39045; %const.h0; v0 = 0; %const.v0; t0 = 0; tf = 800; N = 60000; tspan = linspace(t0, tf, N); X ...

2 meses ago | 0

| accepted