Answered
ode15s using jacobian for a stiff problem
The Jacobian option doesn't have an 'on' value; you have to supply a pointer to a Jacobian function (look at the documentation f...

5 years ago | 0

Answered
Modeling speed and height of a toy rocket using while loops
A little more like this perhaps: g = 9.81 ; m = 0.05 ; f = 16 ; %find velocity and height of the rocket in the first 15s...

5 years ago | 0

| accepted

Answered
How do I plot a transparent contour and its colour?
Possibly by assigning a handle like so: h = contourf(X,Y,ContourData1,[0.2,0.2],'LineWidth',2); then setting h.CurrentObject...

5 years ago | 0

Answered
Error in If else statement
You probably mean if i == 16 || i == 136 as i can't be both 16 and 136 at the same time!

5 years ago | 0

| accepted

Answered
How do I limit angle values in my equations to between 0-90°?
This does it t=[0:0.01:1]; for j=1 : 101 m_ = rad2deg(asin(t(j))); y = zeros(numel(t), numel(m_)); % pre-alloc...

5 years ago | 0

Answered
got confuse .. where is my mistake
c is fixed as the last column. So in [r c] = size(A); for i = 1:r summa = summa + (sum(A(r>=c))); end you are trying to...

5 years ago | 0

Answered
How can i set gap between two xlabels created by text
Like so perhaps: Ej_plot=(2.*180.*(jn-1)./Z); % jn=1:11, Z=11 tp=1:11; h = figure(3); xlim([0 Ej_plot(1,end)]); ...

5 years ago | 0

| accepted

Answered
Trying to write a script to calculate a sum
Simply let k = 2j and then you can write: This will hold for both N even and N odd.

5 years ago | 0

| accepted

Answered
Need help programming a few tricky calculations!!
Here is one way to do the function, assuming you are looking for a numerical output, and that you pass it t as well as n: n = ....

5 years ago | 1

| accepted

Answered
Using logical indexing to modify non-negative elements of a matrix
Try function area = areaCircle(r) nim = r < 0; %negative-index matrix area = zeros(size(r)); area= pi.*r.*r ; area(nim...

5 years ago | 2

| accepted

Answered
Simple boundary value problem and finite difference method
Same question asked and answered here: https://uk.mathworks.com/matlabcentral/answers/596122-find-temperature-vector-using-finit...

5 years ago | 0

| accepted

Answered
Linear Least Square fit
For the linear least squares best fit, try: >> M = [ones(3,1), x.^3]; >> C = M\y C = 0.6667 0.5000 For the var...

5 years ago | 1

Answered
why do I get this answer
This % Euler's Method a=160; Q=400; A=1200; delt = 2.5; t = 0:delt:10; y = zeros(size(t)); for i=1:numel(t)-1 ...

5 years ago | 0

Answered
How solve linear equations
Here is one way of structuring your problem: % Set initial values for Ra, Rb, X0, Y0 Guess = [Ra, Rb, X0, Y0]; % Use them to ...

5 years ago | 0

Answered
why do I get this answer
You can overcome that problem as follows % Euler's Method a=160; Q=400; A=1200; delt = 2.5; t = 0:delt:10; y = zeros(s...

5 years ago | 0

Answered
Draw a 3D aerodynamic nose cone
Instead of X=X*R/2; Y=Y*R/2; use X=X*R/max(y); Y=Y*R/max(y);

5 years ago | 0

| accepted

Answered
May I please get help regarding generating a table showing the values for W, X and p. I have attached the code.
Looking closer, the problem seems to relate to the size of h. Set h = 0.01 and X is real.

5 years ago | 0

Answered
Plotting values results in an empty plot
Try plot(ans(:,1),ans(:,2)) You were just plotting the first value against the second, not one column against the other.

5 years ago | 0

| accepted

Answered
Column Vector Containing the Row Sums of the Elements of A
Matlab has the function "sum". Try help sum.

5 years ago | 0

Answered
How to have array in for loop
Like so: one=1:24; two= 25:48; three=49:72; four=73:96; M=[one;two;three;four]; for i=1:4 j = 1:3; Mne...

5 years ago | 0

Answered
How to implement a mixed boundary conditions into 2D steady state heat conduction equation?
Like this? I've used: (T(1:nx,2) - T(1:nx,1))/dy = 5 and rearranged this to get T(1:nx,1). In addition I've set the y valu...

5 years ago | 0

Answered
Lotka-Volterra simulation using Gillespie algorithm
You have some mismatched vector/matrix sizes. The following works, though you will need to check carefully to see if it does ex...

5 years ago | 0

Answered
How can I solve a set of equations for multiple inputs?
You don't need a for loop if all you are doing is calculating SDelta, Sa, Sm, R and A. Just use Smax = [1000 1000 1500 150...

5 years ago | 0

Answered
Help me to solve ordinary differential equation
The following gets it working, though the output isn't very exciting!. However, you have a number of variables that aren't used...

5 years ago | 0

Answered
Numerical integration over (0, x1)
Need to write fun as fun = @(x) (1./(exp(0.014342./(x*t))-1).*1./x.^4);

5 years ago | 0

Answered
how can i re numbering degree of fredom in FEM after elimination exeeded element??
Look up documentation on inpolygon.

5 years ago | 0

Answered
using euler method for population growth
If you must use the simple Euler method you need to write the equation in the following form: p(i+1) = p(i) + dt*G*(pmax - p(i)...

5 years ago | 0

Answered
4th order Runge-Kutta code that can solve for several intial conditions
Here's a version: % Initial conditions t0=0; x0=0:0.2:1; y0=1:0.2:2; dt=0.1; tz=1; t_range= t0:dt:tz; X = zeros(numel(x0...

5 years ago | 0

| accepted

Answered
linear equation cant solve
"... though I would argue that explaining the problem is more important, ..." I agree. I didn't notice the extra space, just t...

5 years ago | 0

Load more