Answered
linear equation cant solve
Like so rcd = [-1, - 1, 2] ; ucd = rcd/norm(rcd); syms Ax Ay Az Bx Bz T ; eqn1 = [Ax Ay Az]+[0 0 -2*50*9.80665]+[Bx 0 Bz]+ ...

5 years ago | 0

Answered
what y(2) ,y(3), y(4) , y(5) ,by using matlab ?
You need to start with y(1) = 1, not y(0) = 1. Then with y(2) = 5, you can use a for loop: for n=1:3, y(n+2) = 3*y(n+1)-5*y(n)...

5 years ago | 1

Answered
why does ode45 happen this index error?
See the following: global d; d=1; tspan=[0;0.05]; xi=[1;2;pi]; vk=[3;5]; [t,y]=ode45(@TwoWheel2,tspan,xi,[],vk); function...

5 years ago | 0

| accepted

Answered
plotting multiple vectors on one graph
Like this perhaps: >> x = 1:5; >> plot(x,y1,'o-',x,y2,'*-',x,y3,'s-')

5 years ago | 0

Answered
Find temperature vector using finite difference method
Try this L = 2; N = 250; T0 = 300; % boundary condition Tend = 400; % boundary condition h = L/N; xj = 0:h:L; %%%%%%%%%%%...

5 years ago | 0

| accepted

Answered
for loop to repeat specified number of times
If M is your 40448x20 matrix then something like for i = 1:9:40448 K = M(i:i+8,:); ... other calculations with ...

5 years ago | 0

| accepted

Answered
Index exceeds the number of array elements (1).
You should put x_rec = zeros(1000,1); y_rec = zeros(1000,1); just before x_rec(1)=x(1); y_rec(1)=y(1);

5 years ago | 1

Answered
Error in solving differential of spherical Bessel function. How to solve it?
Assuming fcntr is a vector of values then you need lambda0=c0 ./ fcntr; and fnh=@(r1)(diff(sqrt(pi ./ (2*k1a*r1)) .* besselh...

5 years ago | 0

| accepted

Answered
Find Optimum Temperature where Concentration of product vs Time is high.
Does this help: tspan = 0:0.1:3; C0 = [1.; 0]; T = 330:5:360; for i = 1:numel(T) [t,C]=ode45(...

5 years ago | 1

| accepted

Answered
Matrix condition in while loop
I don't know if this solves your problem, but while (abs(EP(i+1,:)-EP(i,:)>0.1)) should probably be while abs(EP(i+1,:)-EP(i,...

5 years ago | 0

| accepted

Answered
ode45 coupled first degree ODEs
Do you mean something like this: [v, z] = ode45(@myode,[0 40],[2 6]); plot(v,z) function dz = myode(~,z) a = 0.4; b = 0.0...

5 years ago | 0

Answered
How to use if statements and for loop to plot the following series?
Try replacing if (j == t) with if (mod(j,2)==1) and if (j == d) with if (mod(j,2)==0)

5 years ago | 0

| accepted

Answered
The force on a cylinder near a wall in viscous potential flows
Here is Cx for you: >> bovera = 1.001:0.2:10; >> Cx = 1./(sqrt(bovera.^2-1)*2*pi); >> plot(bovera,Cx,'o'),grid (Note that Cx...

5 years ago | 0

Answered
Unrecognized function or variable 'x'.
To avoid your error message simply specify the derivatives directly (they are easy to obtain from polynomials). With both initi...

5 years ago | 0

Answered
Solving 4th order ode using ode45
Here's some coding that basically solves the equation. I've no idea what the value of k should really be, but the constants cho...

5 years ago | 0

| accepted

Answered
Solving two dependent two variable ordinary differential equation
Here's the basic syntax. Look up ode45 in the documentation for more detail. tspan = [0 2]; y0 = [0, 0]; [t, y] = ode45(@r...

5 years ago | 0

| accepted

Answered
Error While running a while loop (index exceeds number of array elements)
for j = 1:(i-1) when i = 1 this will lead to a j index of zero. Matlab only likes indices of 1 and greater.

5 years ago | 0

Answered
problem ode45 system of differential equation
This works (I think your value of C is not in the right units): tSpan=[0 2.33e9]; y0=[8.6e7 0 0 55.1]; [tSol,ySol]=ode45(@com...

5 years ago | 0

| accepted

Answered
Making a 'progressive' plot from a scattered matrix.
Look up cumtrapz

5 years ago | 1

| accepted

Answered
Need help on difficulty 3D Plot. - Problem resolved
Here's some code to get you started % Data T=300; k=1.38064852e-23; Ea=7.2*10^(-21); Ed=7.2*10^(-21); Nv=2.5*10^(25)*((0.5...

5 years ago | 0

| accepted

Answered
"find" data range within vector and ensure second index greater than first
How about y = find(A(max(x):end)<3);

5 years ago | 0

| accepted

Answered
Plotting a function with a for loop to have a special scenario for dividing by 0
Try t = -10:0.01:10; for i = 1:length(t) if t(i) ==0 y(i)=1; else y(i) = sin...

5 years ago | 0

| accepted

Answered
Estimate r and K of logistic curve
Since y is your data you first need to invert the data to get z. Then you need to take ln(z) if you want to see a roughly strai...

5 years ago | 0

Answered
How to create a vector and populate it with the first 10 roots using this Newtons method code?
Something more like this perhaps (no need for symbolic maths). f = @(x) x.*tan(x)-0.1; %Function g = @(x) x.*tan(x).^2 + ta...

5 years ago | 1

| accepted

Answered
I have no idea how to start this question
Look at https://uk.mathworks.com/matlabcentral/answers/591166-loop-answers-slightly-out-from-correct-values .

5 years ago | 1

| accepted

Answered
How to speed up the iteration of the for loop and make some further improvement on the below code?
The following, which makes use of fzero to find the value of c that makes F_total equal to zero, runs a lot faster. I've no ide...

5 years ago | 0

| accepted

Answered
How to solve problems with ODE in my SIR model?
Replace y = ode45("epidemia", [0 60], [495; 5; 0]); by y = ode45(@epidemia, [0 60], [495; 5; 0]);

5 years ago | 1

| accepted

Answered
Solving Exponential equation with data
Try a = 0.0093; b = 0.0095; c = 0.0035; d = 0.00185; f = a*(1 - exp(-b*x)) + c*(exp(d*x) - 1); plot(x,y,'o',x,f),grid xlabel...

5 years ago | 0

| accepted

Answered
I am attempting to plot data from an experiment and compare it to a numerical model
Plot as follows. This also gives you the root sum square (RSS) errors x = linspace(3, 4, 5); expmdot_339 = [5.16e-2 1.83e-3...

5 years ago | 1

| accepted

Load more