multiple equations multiple variables solve command does not work
These equations are linear in the unknowns, so can be solved as follows: % M*X = V where X = [b; d; e] % and the coefficien...

3 mesi ago | 1

Is there an error in the if else statement?
Yes, among others! See: L1 = 16.87; %cm L2 = 60.35; L3 = 16.81; L4 = 63.06; L5 = 42.62; L7 = 19.64; theta_1 = 105.47; %de...

3 mesi ago | 1

| accepted

Solving ODE Boundary Value Problem by Finite Difference Method
I think you just need to change b(i+1) = (w*xi(L-xi))/(2*E*I); to b(i+1) = (w*xi*(L-xi))/(2*E*I); ...

3 mesi ago | 1

| accepted

Computing the double integral of a surface
Like this syms x y z = @(x,y) x.^2 + y.^2; surface_int = integral2(z,1,2,4,9); disp(surface_int)

3 mesi ago | 0

| accepted

Mod Euler Method with two ODEs
Like this %Mod_Euler_method Modified Euler's method % [t, w, h] = euler_method(f, a, b, alpha, n) performs Modified Euler's me...

3 mesi ago | 0

| accepted

im having trouble finding the right values for this codes
This should allow you to find the right values, though it might not be quite the way you were tasked to do it! %Initial Conditi...

3 mesi ago | 0

Break the for loop
Something like this perhaps: fib = [1; 1]; its = 0; keepgoing = true; while keepgoing its = its+1; r = rand; ...

3 mesi ago | 0

How to take data on a column matrix (2661 x 1 double) for every 4 row then 3, sequently? So we take data only row 1, 5, 8, 12, 15, 19, 22, ... etc? Thank you.
Here's one way. There's probably a neater way. data=rand(1,2661); n = ceil(2661/3.5); ptr(1)=1; for i = 2:n ptr(i) = 4*(...

3 mesi ago | 0

| accepted

Random draws from conditional multinomial distribution
Something like u = rand(1) if u<0.2 d = 0; elseif u<0.7 d = 2571; elseif u<0.9 d = 2571^2; else d = 25...

3 mesi ago | 0

| accepted

How to define and plot a function with input range?
Like so: pt = @(t) (1 ./ (1 + t .^ 2)).*(t>=-0.5).*(t<=0.5); x = 0:0.01:10; y = 2*pt(x-1) + 4*pt(x-2) + 3*pt(x-3) + pt(x-4); ...

3 mesi ago | 0

| accepted

Plot the slope of a parabola with only the data points being known
Like this? x = linspace(-0.5,0.5,25); %length in (meters) def_3mm_no_grav = -[0.00 5.82e-1 1.08 1.53 1.94 2.30 2.62 2.89 3.12 ...

3 mesi ago | 1

SIRE with vaccine model
Like this tspan = [0 1.5]; options = odeset('Refine', 10, 'RelTol', 1e-4); y0 = [5185000*0.3 5185000*0.7 1 1 0 0 0 0]; [t,...

3 mesi ago | 1

| accepted

Problem with fplot function - displays grey zone instead of functions
Change all the ^ to .^ (i.e. dot^)and the * to .*

3 mesi ago | 1

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

3 mesi ago | 0

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

3 mesi ago | 0

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

3 mesi ago | 0

| accepted

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

3 mesi ago | 0

| accepted

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

3 mesi ago | 0

| accepted

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

3 mesi ago | 0

| accepted

Simplify Matrix decimal to integers
One way is M = [881/2158 985/1393 780/1351 881/2158 -985/1393 780/1351 -881/1079 ...

3 mesi ago | 0

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

3 mesi ago | 0

| accepted

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

3 mesi ago | 0

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

3 mesi ago | 0

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

3 mesi ago | 1

| accepted

calculating angle between line of best fit and x axis
Take the arctangent of the gradient of the straight line.

3 mesi ago | 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 ]; ...

3 mesi ago | 0

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

3 mesi ago | 0

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

4 mesi ago | 0

| accepted