summaryrefslogtreecommitdiff
path: root/191/CH1/EX1.1/Example1_1.sce
blob: 0c77d737c305c1921fc23d9ae62a80c59b2390f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//Illustrating that a small error in data provided can result in big errors.
//with original equations
//X+Y=2 & X+1.01Y=2.01
clear;
clc;
close();
A=[1 1;1 1.01];
B=[2 2.01]';
x=A\B;
disp(x,'Solutions are :')
x=linspace(-0.5,1.5);
y1=2-x;
y2=(2.01-x)/1.01;
subplot(2,1,1);
plot(x,y1)
plot(x,y2,'r')
xtitle('plot of correct equations','x axis','y axis')
//with the equations having some error in data
//X+Y=2 & X+1.01Y=2.02
A=[1 1;1 1.01];
B=[2 2.02]';
x=A\B;
disp(x,'Solutions are :')
subplot(2,1,2);
x=linspace(-1,1);
y1=2-x;
y2=(2.02-x)/1.01;
plot(x,y1)
plot(x,y2,'r')
xtitle('plot of error having equations','x axis','y axis')