Answered
User defined axis for unit impulse sequence
Just add: axis([-5 5 0 1]) after the stem function line.

5 years ago | 0

Answered
Using a vector input in integral function.
Like this? X = 1:5; myvec= [0.5 1.5 2.5 3.5 4.5]; % values corresponding to x = 1,2,3,4,5 vec =@(x) interp1(X,myvec,x); % li...

5 years ago | 1

| accepted

Answered
numerical solution of trancedental equation
Here's a way of finding the first four (positive) roots just using fzero: % First plot the function to see roughly where the ze...

5 years ago | 1

Answered
Solving ODE45 with input vectors
I assume this represents some object sinking through changing desity sea water. The following shows how you might do it, though...

5 years ago | 0

| accepted

Answered
Use fzero with vectors of b and c (parameters)? Can I use for loop?
Might be better to use roots to solve the cubic. For example: % Solutions to x^3 +b*x + c = 0 b = [2 3]; c = [3.5 4]; x = [...

5 years ago | 0

Answered
I can't figure out commands for solving ode with multiple constants. Here is the given: dy/dt = r(1-y/K)y-h = f(y). where h< rK/4. HELP!!
At equilibrium the rate of change of y with respect to t will be zero. i.e. dy/dt = 0 which means that r(1 - y/K)y - h = 0. Thi...

5 years ago | 0

Answered
warning :unable to find explicit solution
There is no explicit solution for k! However, Matlab would have no difficulty in finding numerical values given values for the ...

5 years ago | 0

| accepted

Answered
Dealing with complex integrals of a highly oscillatory type
I don't know in general, but for this particular integral, since cos(x)/x is odd, its contribution to the integral is zero and w...

5 years ago | 0

Answered
Parameter variation in BVP shooting method
The following works: % Shooting Method for Non-Linear ODE k=3.25e8; %Debye length - needs to be calculated. D=4e-9; %separati...

5 years ago | 0

| accepted

Answered
Replace lines with curved lines on my graph
Using spline curve fits perhaps: x=[5,610,1115,1620,2125,2630,3135,3640,4145,4650]; y=[1.5728,1.6011,1.5828,1.583,1.5779,1.5...

5 years ago | 1

| accepted

Answered
Fitting Parameters of ODE to Experimental Data SIR Model
The following works, but you get a lousy fit because of the huge range (orders of magnitude) between s and i and r. The error d...

5 years ago | 0

| accepted

Answered
Integration of numerical date between multiple limits
Use cumtrapz(t,accn)?

5 years ago | 0

Answered
solve IVP with ode45
Looks like your equation is not correct for non-linear pendulum! Try the following: % If u = angle from vertical then d^2u/dt^...

5 years ago | 0

| accepted

Answered
2D plot error
As follows: Gi=0.995; Ea=0.4; k=0.0000862; pi_Q=1; Pi_E=1; m=2.4; T=linspace(40,100,5); y=exp((-Ea/k).*((1./(T+273))-(1/...

5 years ago | 0

| accepted

Answered
How to solve this problem in MATLAB?
The following calculates the normal cumulative distribution function for mean 0 and stadard deviation 1: CDF = (1/2)*(1+erf(x/s...

5 years ago | 0

Answered
Smooth decay of a function
How about writing a function like: function mfn = mvalue(T,Tc,a,b,y) disc = b^2 - 4*y*a*(T - Tc); ...

5 years ago | 0

Answered
Solving non-linear ode
ODE45 solves first order equations, so represent your second order one as two first order ones: ODE45 will then automatically...

5 years ago | 0

Answered
4th order runge kutta for spring mass sytem
I think your definition of f2 is causingthe problem. Shouldn't it be: f2=@(t,y1,y2)(Fo/m*sin(w*t)-2*z*wn*y2-wn*y1*abs(y1));

5 years ago | 1

| accepted

Answered
PLOTTING it h h
I guess you want to plot Temperature as a function of time. Something like this perhaps: % Data T1 = 79.5; % temperature at t...

5 years ago | 0

Answered
How can one create this matrix?
This will do it: n = 5; reps = 4; c1 = ones(n,1)*(1:reps); c1 = c1(:); c2 = (ones(reps,1)*(1:n))'; c2=c2(:); M = [c1 c2];

5 years ago | 0

Answered
Programming a summation equation
Looks like you are trying to use j as both a loop counter and as sqrt(-1). I assume the latter is what is needed in the exponen...

5 years ago | 0

Answered
how to use solve() without a 'z' variable solution
The following gives real results. %DATA alfa = deg2rad(30); b = 0.14; L = b; m = L*sin(alfa); k = L*sin(alfa); pendiente = 0....

5 years ago | 1

| accepted

Answered
what is wrong in my square wave code it isnt running
You have 30 values of t and only 8 values of a. You need to have the same number of each.

5 years ago | 0

| accepted

Answered
Fit data function of 2 independent and one dependent variables
Make sure X, Y and Data are column vectors. Then create matrix M M = [X Y X.*Y ones(length(X),1)]; Calculate k = M\Data ...

5 years ago | 0

| accepted

Answered
Defining time every step in the loop
Are you meant to use one of Matlab's ODE solvers? If so, the following might do: %% Times tInitial = 0; %initial time [s] ...

5 years ago | 0

| accepted

Answered
ode23s Inputs must be floats, namely single or double.
Delete these two lines in your function and it works: syms x1 x2 x3 x4 x5 v1 v2 v3 v4 v5; x = [ x1 , x2 , x3 , x4...

5 years ago | 1

| accepted

Answered
Numerical computation using Matlab
Here's a (not very elegant!) way: Ls = 0.090; r1 = 0.035; Ks = 445e3; xp = 0.1403; theta0 = 0; TT = 0:50:500; Theta = z...

5 years ago | 0

Answered
How to create a histogram with weighted values from an array?
This will do it (though there might well be a neater way!): A = [70 90 80; 90 90 90; 80 60 70]; B = [0.5 0.8 1.0; 0.2 0.5 1.0;...

6 years ago | 0

| accepted

Answered
How to get all value with for loop
Use a counter? Something like the following perhaps: counter = 0; for ii=1:length(Nodelocation(:,1)) for jj=1:length(UElo...

6 years ago | 0

Answered
Matrix multiplication with constant
k is 1x20 >> RR=5; RS=750:150:3600; for i=1:length(RS) k(i)=RR.*RS(i); end >> k k = Columns 1 through 11 ...

6 years ago | 0

| accepted

Load more