Answered
creatting a polygon in matlab
You could also use the patch function x = [0 0:30 30 0]; y = [0 10+exp((-(x(2:end-2)-15).^2)/10) 0 0]; patch(x,y,'r')

5 years ago | 0

Answered
Why solution vector of system of linear equations on MATLAB differs from that on EXCEL
Matlab is dependable! Haven't tried in Excel, but the Matlab results are consistent: A=0.012271846; m1=2; m2=2; m3=0.5; m4=0.5;...

5 years ago | 0

Answered
How to maintain uniformity in the xtick and ytick labels? Also, how to adjust the legend position in a non-interactive setup.
I'm not sure what you mean by the y-tick spacing being different from that of the x-ticks. I've let the fonts retain their defa...

5 years ago | 0

| accepted

Answered
How can I solve non-linear differential equations?
Here's how you might structure your code. Clearly, you will need to use your own constants and initial conditions etc. tspan ...

5 years ago | 0

Answered
how can i make matrix 1 1/2 1/3 1/4 ... 1/n
This is built in to Matlab. Try help hilb in the workspace.

5 years ago | 0

| accepted

Answered
How to make a UDF that calculates the Midpoint Rule
Don't confuse x with t! The following might help. I'll leave you to turn it into a function: f = @(x,y) x+y; % function of t...

5 years ago | 0

Answered
Regarding Index in position 1 exceeds array bounds (must not exceed 1) error
You have defined LB and UB as 1x2 vectors, but in the line giving an error you are trying to access elements i, j where i can b...

5 years ago | 0

| accepted

Answered
Why does the array only work once?
You need element by element multiplication and division: % Givens AB = 150; BD = 200; Theta = 20:120; Mb = 2.5; %Solutio...

5 years ago | 1

Answered
Array indices must be positive integers or logical values
The following works x = [0.888: 0.01: 1.178]; %x values for n = 1: 1: length(x) %must have different vector because varia...

5 years ago | 0

| accepted

Answered
Getting error in the Q(1) = IC, how do i apply Forward Euler to this
See my last reply here: https://uk.mathworks.com/matlabcentral/answers/601966-morse-potential-solve-using-matlab

5 years ago | 0

Answered
Problem in simulating if condition
You can replace your if statement with % Assuming there are 100 steps in T nhi=(Nd/2)+(sqrt(((Nd/2)^2)+(ni(51:100).^2))); nlo...

5 years ago | 0

| accepted

Answered
How to solve a system of differential equations using ODE45 with a different end conditions?
Look up ODE Event Location in the Matlab documentation.

5 years ago | 1

Answered
Rolling a Fair 6-Sided Die Until Two Consecutive Rolls Have the Same Value
I think the above will produce a probability, rather than an expected value. Try NTrials = 1000; N = zeros(NTrials,1); for T...

5 years ago | 0

Answered
Plot two variable sum function
Looks like you are translating from SMath Studio to MATLAB. The following is one way to do what you want: % Basic data beta(1...

5 years ago | 1

| accepted

Answered
Solving non linear equation
Use cosd instead of cos. cosd assumes the argument is in degrees, cos assumes the argument is in radians.

5 years ago | 0

Answered
Varying parameters in ODE and plot the different outcomes
More like this perhaps: timeSpan = [0 50]; % S I1 I2 R S I1 I2 R S I1 I2 R P0 = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, ...

5 years ago | 0

Answered
Rules of Reynolds Averaging
uprime doesn't mean du/dt here. It means u - umean. u = [1,3,6,8,24]; umean = mean(u); uprime = u-umean; mean(uprime) an...

5 years ago | 1

| accepted

Answered
Dsolve giving implicit solution
Look at documentation on ode45. You don't need a symbolic solution if you just want to get T as a function of t. Like the fol...

5 years ago | 0

| accepted

Answered
How to solve this equation Numerically [VPASOLVE]
You can solve it numerically using fzero. Ism=200; Wb=1500; speedend=6000; Ws=Wb:15:speedend; Idn = zeros(size(Ws)); Idn0 ...

5 years ago | 0

| accepted

Answered
using solve, 4eqs 4unkns
There are, in fact, an infinite number of possible solutions. When t = 0 the equations can be written and manipulated as follow...

5 years ago | 0

Answered
Vectorisation of a Lagrange polynomial
In your expression dfdx(j) = f(j-1).*(x(j)+x(j+1))./((x(j-1)+x(j)).*(x(j-1)+x(j+1)))... +f(j).*(2.*x(j)+x(j-1)-x(j+1))./((...

5 years ago | 0

Answered
how can i plot this code ?
You need to plot them separately as they have completely different 'x' values (indeed the ri values seem unbelievably small!): ...

5 years ago | 0

Answered
How to solve an equation using numerical solver in Matlab?
Look up documentation on fzero.

5 years ago | 0

| accepted

Answered
need check for Bisection Method
When you are close to the solution it won't much matter if you use b-p or b-a. However, you shoud probably use abs((b-p)/(b0-a...

5 years ago | 0

| accepted

Answered
fixed point Iterative method for finding root of an equation
I defer to John on the guarantee. Certainly it's possible with x - exp(-x) = 0: % x - exp(-x) = 0; rearrange as x = exp(-x) ...

5 years ago | 2

Answered
whenever i use individual value of time (Tv) the output function (F) giving right value but using time in the form of loop ,output function gives wrong result for all.How to fix this ?
You missed a set of brackets connecting TV to 273. c1 = 3.742*10.^8; c2 = 1.43878*10.^4; sigma = 5.67*10.^-8; lamda_1 = 8; ...

5 years ago | 1

| accepted

Answered
Symsum every other step
Does this help: syms k p a = [1 5]; f=@(k,p) (2*k)^2*p; f1=symsum(f,k,a) f1 = 220*p

5 years ago | 0

| accepted

Answered
Morse Potential solve using Matlab
Do you mean like the following (where I've just used 1 atom): If so, then something like the following coding might do: %% S...

5 years ago | 0

| accepted

Answered
bessel function derivatives problem
Like so:

5 years ago | 0

| accepted

Answered
Density-Temperature diagram
Perhaps you should have T instead of x in the last line (and have you got the two parameters the wrong way round? You want to ge...

5 years ago | 0

Load more