2008_hw1 - ) ylabel( 'h(m)' ) title( 'Comparison of Linear...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Following M-File is used to obtain results; clc clear all close all t=0:1:20; dt=1; qin=0.1; qinnon=2.1; y=zeros(20,1); %% Dimension of the array is defined for linear model ynon=zeros(20,1); %% Dimension of the array is defined for non-linear model y(1)=0; %% Initial condition for linear model(Actually it was defined above) ynon(1)=4; %% Initial condition for non-linear model for k=1:20 y(k+1)=y(k)+dt*(-1/4*y(k)+qin); %%Euler integration for linear model ynon(k+1)=ynon(k)+dt*(-sqrt(ynon(k))+qinnon); %%Euler integration for non-linear model error(k+1)= 100*(ynon(k)-(y(k)+4))/ynon(k); end y(20)+4 %%Final water level for linear model ynon(20) %%Final water level for non-linear model plot(t,4+y, 'r-' ) %% Linear Model xlabel( 'Time'
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ) ylabel( 'h(m)' ) title( 'Comparison of Linear and Non-Linear Model' ) hold on plot(t,ynon) %% Non-linear Model figure plot(t,error) xlabel( 'Time' ) ylabel( 'Error' ) title( 'Relative Percent Error' ) error= 100*(ynon(20)-(y(20)+4))/ynon(20) Following results are obtained; 2 4 6 8 10 12 14 16 18 20 4 4.05 4.1 4.15 4.2 4.25 4.3 4.35 4.4 4.45 4.5 Time h(m) Comparison of Linear and Non-Linear Model For linear model h(20)= 4.3983 integrating by Euler Method (RK2) For non-linear model h(20)= 4.4077 integrating by Euler Method(RK2) And relative percent error between non-linear model and linear model is e=0.2138 2 4 6 8 10 12 14 16 18 20 0.05 0.1 0.15 0.2 0.25 Time Error Relative Percent Error...
View Full Document

Page1 / 3

2008_hw1 - ) ylabel( 'h(m)' ) title( 'Comparison of Linear...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online