Answered
Error using ode45
You need to declare cpAB as a global variable in P12_7b. Better to try to do without global variables! You have some other pro...

5 years ago | 0

Answered
How to get the coefficient of the function using non-linear regression analysis?
Needs to be more like this: xm = 0:0.5:5; ym = [0 0.223904 0.323333 0.372308 0.359143 0.332033 0.278462 0.243394 ... 0.2...

5 years ago | 0

| accepted

Answered
Solving a taylor serie with matlab. Homework question
There's a multiplier of (-1)^(i-1) that you need. Try tol=1e-8; s=0; i=1; k = -2/3; s = k; err = 1; while err > tol ...

5 years ago | 0

| accepted

Answered
Function that should be continuous isn't continuously plotted?
The function is continuous at (0,0); it has a removable singularity. Try using [x,y] = meshgrid(-2+eps:0.2:2+eps); eps is Mat...

5 years ago | 1

| accepted

Answered
How do I set multiple columns as the same variable?
Have you tried UT = xlsread(velocity data.xlsx, 'A3:X2883'); or whatever, the overall range values are. Then Power= 0.5*rho...

5 years ago | 0

| accepted

Answered
differentiation in matlab of two functions
a = @(theta) exp(2j*pi*A*[cos(theta);sin(theta)]); dadtheta = @(theta) 2j*pi*A*[-sin(theta);cos(theta)]*a(theta);

5 years ago | 0

Answered
Not sure what's happening in this code and not sure where to come from here.
You are not keeping track of parameters through time. Try L = 30; m = 68.1; c_d = 0.25; k = 40; gamma = 8; g = 9.81; h = ...

5 years ago | 0

Answered
How to set y to different functions depending on the limits of T
Might be easier as T = -20:0.5:20; ai = 0.5; a0 = 0.3; y = ai + (a0 - ai)*((T+10)/20); id = find(T<=-10); y(id) = ai; id ...

5 years ago | 0

| accepted

Answered
Police increase of X/Y label in plot
I think you are referring to the Properties of the text and coordinates. You can add properties of Fontsize and Fontweight to x...

5 years ago | 0

| accepted

Answered
Monte Carlo integration of functions to the 3rd power
Here's a simple MC calculation of the integration of your function f = @(t) -0.1*t.^3 + 0.58*t.^2.*cosh(-1./(t+1)) + exp(t/2.7)...

5 years ago | 1

| accepted

Answered
How to solve a symbolic angle for an equation without complex numbers
You could find the angle with fzero: %Input Values %Shear_max=560*(10^6); %yield stress from data sheet g_max_A=172.369*(10^6...

5 years ago | 0

| accepted

Answered
How can I define the variable handles for this code. A is a numerical value not text "Undefined variable handles or class "handles.A"
Do you want something like this? xo = 0.1; vo = 3; m = 1; c =10; k = 100; wn = sqrt(k/m); c_c = 2*m*wn; zeta = c/c_c; t = li...

5 years ago | 0

Answered
how to solve a system of equations in matlab
Try this f = @(x) (x+2).*(x<=0) + (-x+2).*(x>0); (x<=0) returns 1's where it's true and 0 where it's false. Similarly for (x>...

5 years ago | 0

| accepted

Answered
Trying to plot Fourier series, but just getting a straight line??
When I run this A0=1; T=1; n=6; t = 0 : T/256 : T; nn = length(t); f = zeros(n,nn); s = zeros(nn); for ii = 1:n for j...

5 years ago | 0

Answered
Wha'ts wrong with this?
Try f = @(x) sin(x+1)*sqrt(x+1); p = polyfit([1,2,3,4],[f(1),f(2),f(3),f(4)],3); x = 1:0.01:4; y = polyval(p,x); plot([1,2,...

5 years ago | 2

| accepted

Answered
Trying to plot Fourier series, but just getting a straight line??
Replace f(ii) = f(ii,j) + (4*A0/(2*ii-1)*pi) * sin(2*pi*(ii-1)*t(j)); with f(ii,j) = f(ii,j) + 4*A0/((2*ii-1)*pi) *...

5 years ago | 0

| accepted

Answered
Heaviside function is not integrated
You could do it this way, without the symbolic stuff: %% Castigliano E=210e9; %e-modulus aluminium=69 steel-210 rho=8...

5 years ago | 1

| accepted

Answered
How would I plot a piecewise summation.
Something like this? tau = 1; t = 0:0.1:10; n = ceil(t/tau); for i = 1:numel(n) S = 0; for k = 1:n(i) ...

5 years ago | 1

| accepted

Answered
oblique throw for golf ball
A little more like this perhaps: v0 = [15:60]; %initial speed a = [15:60]; %angle g = 9.81; %gravitational acceleration ...

5 years ago | 1

| accepted

Answered
Using Linear congruential to generate 10,000 uniform random variables
You need an intial value for X(1); and you need to set for n=2:10000 X(n+1)=mod((a*X(n)+c), m); end

5 years ago | 0

| accepted

Answered
Not able to stop value of iterations
Better as something like tol = 10^-8; % or whatever you desire maxiter = 100; % ditto err = 1; its = 0; while ...

5 years ago | 0

Answered
How can I store values in empty matrix to plot later?
You need to wotk with normalized population numbers. You can renormalize at the end. %Epidemic Simulation %Author: James Metz...

5 years ago | 0

| accepted

Answered
Fitting multiple datasets to non-linear coupled ODE's - fminsearch
Why not just use errT=norm(cellHND - chND)+norm(cellLND - clND); instead of looping through the sums.

5 years ago | 0

Answered
why is there an error in line 13 of my coding ?
In addition to Walter's correction, note that f and d contain a different number of elements, so element by element operations w...

5 years ago | 0

Answered
why do I have an error on the length function?
You have misspelled length.

5 years ago | 1

Answered
How to plot ode
First, you should combine your three "prom" ode functions into one IC = [n0 m0 h0]; [t, NMH] = ode45(@(t,nmh) prom(t,nmh,V1), ...

5 years ago | 0

| accepted

Answered
Grouping In Pairs the Coefficients of an Array and Computing the Average of each group
Use reshape to get the pairs in two rows. AG = reshape(A,2,4); Then the average of each group is simply Agav = mean(AG);

5 years ago | 0

| accepted

Answered
I'm trying to solve this problem in MatLab
In terms of real numbers the integral is only defined for -1<=x<=1. By making the substitution x^2 = sin(theta) where -pi/2<=t...

5 years ago | 0

Answered
Plot 4 diagrams in one plot
Like this? mu=[0 0.1 1 10]; tspan=[0 20*pi]; x0=0.5;dx0=0; IC=[x0 dx0]; % initial conditions for i=1:4 dxdt=@(t,x)[x(2); ...

5 years ago | 0

Answered
Raising a negative value to a fraction power?
Exponentiation has a higher priority than negation, so -2^1.2 is -(2^1.2), this results in a negative real. On the other had (-...

5 years ago | 1

| accepted

Load more