MATLAB Answers

# P(t)=25sin(35t) euler method

1 view (last 30 days)
Fernando Piedra on 12 Nov 2020
Commented: VBBV on 23 Nov 2020
%i need help with my getder file which take the derivative of the funtion.
%there are 3 file main where define all variables getder which i obtain the derivative
%and box_solve to solve and create a plot using eulers or RK method.
%Many thanks in advance
%main file
v0 = 0;
s0 = 0;
m = .5;
k = 75;
%getder file to obtain a the derivative
function xdot = getder(t,x)
x = [s;v];
a = (1/m)*(25*sin(45*t)-k*so);
xdot = [s;a];
%box_solve file to solve equation through euler method or Rk.
function [t,x] = box solve(x0,tlim,dt,solve_type)
if st == 1 %solve type allow operator to
t = (to:dt:tf).'
L = length(t);
x = xeros([l,2])
x(1,:) = xo.'
for n =1:L
x(n+1,:) = x(n,:)+dt*geter(t(n),x(n,:));
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Answers (1)

VBBV on 23 Nov 2020
Edited: VBBV on 23 Nov 2020
%if true
x = zeros(1,2);
There is no xeros function im matlab
##### 2 CommentsShowHide 1 older comment
VBBV on 23 Nov 2020
%if true
function [t,x] = boxsolve(x0,tlim,dt,solve_type)
Function names must not contain spaces in matlab. It must be continuous

Sign in to comment.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!