//wykresy płaskie
clear;//wyczyszczenie pamięci
xdel(winsid()); //wyczyszczenie (zamknięcie) wszystkich okien clc; //wyczyszczenie konsoli
t=linspace(0, 2*%pi, 100); //(obliczenie od do 2pi, liczba y=sin(t); //funkcja którą liczymy, czyli sinus plot2d(t,y //wygenerowanie wykresu liczonej funkcji y=f(t)
//figury
Narysować trójkąt o wierzchołkach w punktach: (0,0), (10,1), clear();
x=[0,10,5,0];
y=[0,1,7,0];
plot(x,y)
zadanie 1:
t=linspace(0, 2*%pi, 100);
y=sin(t)
plot2d(t,y)
zadanie2:
narysowac trojkat w werzcholkach w pktach:
(0,0), (10,1), (5,7).
clear();
x=[0,10,5,0]
y=[0,1,7,0]
plot(x,y)
zadanie3:
narysuj wykres funkcji y=x^2
function k=kwadrat(x)
k=x^2
endfunction
zadanie4:
function y=f(x)
y=x^2
endfunction
x=-20:20
plot(x,f(x))
//formatowanie
// style linii
plot(x,y,'-'); linia ciagla (domyslnie)
plot(x,y,'- -'); linia przerywana
plot(x,y,':'); linia kropkowana
plotx,y,'-.'); linia kreskowo-kropkowa
//kolory //znaczniki
symbol kolor + plus
r czerwony o kółko
g zielony . kropka
b niebieski * gwiazdka
c cyan x kzyżyk
m magenta s 'square' kwadrat
y żółty d 'diamond'
k czarny ^,<,>,v - trójkątne znaczki
w biały 'pentagram' pięcioramienna gwiazda
//podwykresy
polecenie subplot()
subplot(m,n,o)
m-ilosc wierszy, n-ilosc kolumn na jaka dzielimy okno graficzne, o-nr wydzielonej czesci okna
subplot(2,2,2);
plot(x,y,'ro-.')
subplot(2,2,2);
subplot(2,2,3);
plot(x,y,'mo-.')
xgrid()
subplot(2,2,4);
plot(x,2*y,x,y);
xgrid()
//zadeklarujmy zmienną
a=2^(-52)
1+a==1
1+a/2==1
// ĆWICZENIE 2: - rozwiązanie ukł. równań liniowch postaci Ax=b
A=[1, 1, 1, -1; 1, -1, -1, 1; 2, 1, -1, 2; 3, 1, 2, -1]
b=[2, 0, 9,7 ]'
x1=linsolve(A,-b)
A*x1-b
P1=norm(A*x1-b)
x2=inv(A)b
p2=norm(A*x2-b)
sA=sparse(A)
x3=lusolve(sA,b)
żeby zamienic nasze wyniki jest funkcja: int32(x)...
________________________________SCILAB____________________
Wykonanie rozruchu:
ładowanie środowiska początkowego
-->x=-10:10
x =
- 10. - 9. - 8. - 7. - 6. - 5. - 4. - 3. - 2. - 1. 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
-->y=x^2
y =
column 1 to 19
100. 81. 64. 49. 36. 25. 16. 9. 4. 1. 0. 1. 4. 9. 16. 25. 36. 49. 64.
column 20 to 21
81. 100.
-->plot(x,y)
-->t=linspace(0, 2*%pi, 100)
t =
column 1 to 10
0. 0.0634665 0.1269330 0.1903996 0.2538661 0.3173326 0.3807991 0.4442656 0.5077321 0.5711987
column 11 to 19
0.6346652 0.6981317 0.7615982 0.8250647 0.8885313 0.9519978 1.0154643 1.0789308 1.1423973
column 20 to 29
1.2058638 1.2693304 1.3327969 1.3962634 1.4597299 1.5231964 1.586663 1.6501295 1.713596 1.7770625
column 30 to 39
1.840529 1.9039955 1.9674621 2.0309286 2.0943951 2.1578616 2.2213281 2.2847947 2.3482612 2.4117277
column 40 to 48
2.4751942 2.5386607 2.6021272 2.6655938 2.7290603 2.7925268 2.8559933 2.9194598 2.9829264
column 49 to 58
3.0463929 3.1098594 3.1733259 3.2367924 3.3002589 3.3637255 3.427192 3.4906585 3.554125 3.6175915
column 59 to 67
3.6810581 3.7445246 3.8079911 3.8714576 3.9349241 3.9983907 4.0618572 4.1253237 4.1887902
column 68 to 76
4.2522567 4.3157232 4.3791898 4.4426563 4.5061228 4.5695893 4.6330558 4.6965224 4.7599889
column 77 to 86
4.8234554 4.8869219 4.9503884 5.0138549 5.0773215 5.140788 5.2042545 5.267721 5.3311875 5.3946541
column 87 to 95
5.4581206 5.5215871 5.5850536 5.6485201 5.7119866 5.7754532 5.8389197 5.9023862 5.9658527
column 96 to 100
6.0293192 6.0927858 6.1562523 6.2197188 6.2831853
-->y=sin(t)
y =
column 1 to 10
0. 0.0634239 0.1265925 0.1892512 0.2511480 0.3120334 0.3716625 0.4297949 0.4861967 0.5406408
column 11 to 20
0.5929079 0.6427876 0.6900790 0.7345917 0.7761465 0.8145760 0.8497254 0.8814534 0.909632 0.9341479
column 21 to 29
0.9549022 0.9718116 0.9848078 0.9938385 0.9988673 0.9998741 0.9968548 0.9898214 0.9788024
column 30 to 39
0.9638422 0.9450008 0.9223543 0.8959938 0.8660254 0.8325699 0.7957618 0.7557496 0.7126942 0.666769
column 40 to 48
0.6181590 0.5670599 0.5136774 0.4582265 0.4009305 0.3420201 0.2817326 0.2203105 0.1580014
column 49 to 57
0.0950560 0.0317279 - 0.0317279 - 0.0950560 - 0.1580014 - 0.2203105 - 0.2817326 - 0.3420201 - 0.4009305
column 58 to 67
- 0.4582265 - 0.5136774 - 0.5670599 - 0.6181590 - 0.666769 - 0.7126942 - 0.7557496 - 0.7957618 - 0.8325699 - 0.8660254
column 68 to 76
- 0.8959938 - 0.9223543 - 0.9450008 - 0.9638422 - 0.9788024 - 0.9898214 - 0.9968548 - 0.9998741 - 0.9988673
column 77 to 86
- 0.9938385 - 0.9848078 - 0.9718116 - 0.9549022 - 0.9341479 - 0.909632 - 0.8814534 - 0.8497254 - 0.8145760 - 0.7761465
column 87 to 95
- 0.7345917 - 0.6900790 - 0.6427876 - 0.5929079 - 0.5406408 - 0.4861967 - 0.4297949 - 0.3716625 - 0.3120334
column 96 to 100
- 0.2511480 - 0.1892512 - 0.1265925 - 0.0634239 - 2.449D-16
-->plot2d(t,y)
-->y=sin(t)
y =
column 1 to 10
0. 0.0634239 0.1265925 0.1892512 0.2511480 0.3120334 0.3716625 0.4297949 0.4861967 0.5406408
column 11 to 20
0.5929079 0.6427876 0.6900790 0.7345917 0.7761465 0.8145760 0.8497254 0.8814534 0.909632 0.9341479
column 21 to 29
0.9549022 0.9718116 0.9848078 0.9938385 0.9988673 0.9998741 0.9968548 0.9898214 0.9788024
column 30 to 39
0.9638422 0.9450008 0.9223543 0.8959938 0.8660254 0.8325699 0.7957618 0.7557496 0.7126942 0.666769
column 40 to 48
0.6181590 0.5670599 0.5136774 0.4582265 0.4009305 0.3420201 0.2817326 0.2203105 0.1580014
column 49 to 57
0.0950560 0.0317279 - 0.0317279 - 0.0950560 - 0.1580014 - 0.2203105 - 0.2817326 - 0.3420201 - 0.4009305
column 58 to 67
- 0.4582265 - 0.5136774 - 0.5670599 - 0.6181590 - 0.666769 - 0.7126942 - 0.7557496 - 0.7957618 - 0.8325699 - 0.8660254
column 68 to 76
- 0.8959938 - 0.9223543 - 0.9450008 - 0.9638422 - 0.9788024 - 0.9898214 - 0.9968548 - 0.9998741 - 0.9988673
column 77 to 86
- 0.9938385 - 0.9848078 - 0.9718116 - 0.9549022 - 0.9341479 - 0.909632 - 0.8814534 - 0.8497254 - 0.8145760 - 0.7761465
column 87 to 95
- 0.7345917 - 0.6900790 - 0.6427876 - 0.5929079 - 0.5406408 - 0.4861967 - 0.4297949 - 0.3716625 - 0.3120334
column 96 to 100
- 0.2511480 - 0.1892512 - 0.1265925 - 0.0634239 - 2.449D-16
-->plot2d(t,y)
-->y=sin(t)
y =
column 1 to 10
0. 0.0634239 0.1265925 0.1892512 0.2511480 0.3120334 0.3716625 0.4297949 0.4861967 0.5406408
column 11 to 20
0.5929079 0.6427876 0.6900790 0.7345917 0.7761465 0.8145760 0.8497254 0.8814534 0.909632 0.9341479
column 21 to 29
0.9549022 0.9718116 0.9848078 0.9938385 0.9988673 0.9998741 0.9968548 0.9898214 0.9788024
column 30 to 39
0.9638422 0.9450008 0.9223543 0.8959938 0.8660254 0.8325699 0.7957618 0.7557496 0.7126942 0.666769
column 40 to 48
0.6181590 0.5670599 0.5136774 0.4582265 0.4009305 0.3420201 0.2817326 0.2203105 0.1580014
column 49 to 57
0.0950560 0.0317279 - 0.0317279 - 0.0950560 - 0.1580014 - 0.2203105 - 0.2817326 - 0.3420201 - 0.4009305
column 58 to 67
- 0.4582265 - 0.5136774 - 0.5670599 - 0.6181590 - 0.666769 - 0.7126942 - 0.7557496 - 0.7957618 - 0.8325699 - 0.8660254
column 68 to 76
- 0.8959938 - 0.9223543 - 0.9450008 - 0.9638422 - 0.9788024 - 0.9898214 - 0.9968548 - 0.9998741 - 0.9988673
column 77 to 86
- 0.9938385 - 0.9848078 - 0.9718116 - 0.9549022 - 0.9341479 - 0.909632 - 0.8814534 - 0.8497254 - 0.8145760 - 0.7761465
column 87 to 95
- 0.7345917 - 0.6900790 - 0.6427876 - 0.5929079 - 0.5406408 - 0.4861967 - 0.4297949 - 0.3716625 - 0.3120334
column 96 to 100
- 0.2511480 - 0.1892512 - 0.1265925 - 0.0634239 - 2.449D-16
-->plot2d(t,y)
-->x=[0,10,5,0]
x =
0. 10. 5. 0.
-->y=[0,1,7,0]
y =
0. 1. 7. 0.
-->plot(x,y)
-->function y=f(x)
-->y=x^2
-->endfunction
-->x=-20:20
x =
column 1 to 19
- 20. - 19. - 18. - 17. - 16. - 15. - 14. - 13. - 12. - 11. - 10. - 9. - 8. - 7. - 6. - 5. - 4. - 3. - 2.
column 20 to 39
- 1. 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18.
column 40 to 41
19. 20.
-->plot(x,f(x))
-->
-->plot(x,f(x)
!--error 3
Czekam na prawy nawias.
-->plot(x,f(x))
-->plot(x,f(x),'b-.')
-->function y=f(x)
-->y=2x^2+5x-3
-->endfunction
y=2x^2+5x-3
!--error 276
Brak operatora, przecinka lub średnika.
at line 2 of function f called by :
endfunction
-->function y=f(x)
-->y=2x^2+5x-3
-->endfunction
y=2x^2+5x-3
!--error 276
Brak operatora, przecinka lub średnika.
at line 2 of function f called by :
endfunction
-->endfunction;
!--error 16
Błędne polecenie!.
-->function k=2x^2+5x-3
!--error 37
Nieprawidłowa funkcja.
-->function y=f(x)
-->y=2*x^2+5*x-3
-->endfunction
Ostrzeżenie: redefiniowanie funkcji: f . Użyj funcprot(0) aby uniknąć tego komunikatu.
-->x=-10:0.1:10
x =
column 1 to 9
- 10. - 9.9 - 9.8 - 9.7 - 9.6 - 9.5 - 9.4 - 9.3 - 9.2
column 10 to 18
- 9.1 - 9. - 8.9 - 8.8 - 8.7 - 8.6 - 8.5 - 8.4 - 8.3
column 19 to 27
- 8.2 - 8.1 - 8. - 7.9 - 7.8 - 7.7 - 7.6 - 7.5 - 7.4
column 28 to 36
- 7.3 - 7.2 - 7.1 - 7. - 6.9 - 6.8 - 6.7 - 6.6 - 6.5
column 37 to 45
- 6.4 - 6.3 - 6.2 - 6.1 - 6. - 5.9 - 5.8 - 5.7 - 5.6
column 46 to 54
- 5.5 - 5.4 - 5.3 - 5.2 - 5.1 - 5. - 4.9 - 4.8 - 4.7
column 55 to 63
- 4.6 - 4.5 - 4.4 - 4.3 - 4.2 - 4.1 - 4. - 3.9 - 3.8
column 64 to 72
- 3.7 - 3.6 - 3.5 - 3.4 - 3.3 - 3.2 - 3.1 - 3. - 2.9
column 73 to 81
- 2.8 - 2.7 - 2.6 - 2.5 - 2.4 - 2.3 - 2.2 - 2.1 - 2.
column 82 to 90
- 1.9 - 1.8 - 1.7 - 1.6 - 1.5 - 1.4 - 1.3 - 1.2 - 1.1
column 91 to 99
- 1. - 0.9 - 0.8 - 0.7 - 0.6 - 0.5 - 0.4 - 0.3 - 0.2
column 100 to 108
- 0.1 0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7
column 109 to 117
0.8 0.9 1. 1.1 1.2 1.3 1.4 1.5 1.6
column 118 to 126
1.7 1.8 1.9 2. 2.1 2.2 2.3 2.4 2.5
column 127 to 135
2.6 2.7 2.8 2.9 3. 3.1 3.2 3.3 3.4
column 136 to 144
3.5 3.6 3.7 3.8 3.9 4. 4.1 4.2 4.3
column 145 to 153
4.4 4.5 4.6 4.7 4.8 4.9 5. 5.1 5.2
column 154 to 162
5.3 5.4 5.5 5.6 5.7 5.8 5.9 6. 6.1
column 163 to 171
6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.
column 172 to 180
7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9
column 181 to 189
8. 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8
column 190 to 198
8.9 9. 9.1 9.2 9.3 9.4 9.5 9.6 9.7
column 199 to 201
9.8 9.9 10.
-->plot(x,f(x))
-->subplot(2,2,2);
-->plot(x,y,'ro-.')
!--error 10000
plot: Nieprawidłowy rozmiar argumentów 'X' i 'Y': niezgodne wymiary.
at line 93 of function checkXYPair called by :
at line 233 of function plot called by :
plot(x,y,'ro-.')
-->
-->subplot(2,2,2);
-->subplot(2,2,3);
-->plot(x,y,'mo-.')
!--error 10000
plot: Nieprawidłowy rozmiar argumentów 'X' i 'Y': niezgodne wymiary.
at line 93 of function checkXYPair called by :
at line 233 of function plot called by :
plot(x,y,'mo-.')
-->xgrid()
-->subplot(2,2,4);
-->plotx,2*y,x,y);
!--error 4
Niezdefiniowana zmienna: plotx
-->xgrid()
-->subplot(2,2,2);
-->plot(x,y,'ro-.')
!--error 10000
plot: Nieprawidłowy rozmiar argumentów 'X' i 'Y': niezgodne wymiary.
at line 93 of function checkXYPair called by :
at line 233 of function plot called by :
plot(x,y,'ro-.')
-->
-->subplot(2,2,2);
-->subplot(2,2,3);
-->plot(x,y,'mo-.')
!--error 10000
plot: Nieprawidłowy rozmiar argumentów 'X' i 'Y': niezgodne wymiary.
at line 93 of function checkXYPair called by :
at line 233 of function plot called by :
plot(x,y,'mo-.')
-->xgrid()
-->subplot(2,2,4);
-->plot(x,2*y,x,y);
!--error 10000
plot: Nieprawidłowy rozmiar argumentów 'X' i 'Y': niezgodne wymiary.
at line 93 of function checkXYPair called by :
at line 233 of function plot called by :
plot(x,2*y,x,y);
-->xgrid()
-->a=2^(-52)
a =
2.220D-16
-->1+a==1
ans =
F
-->1+a/2==1
ans =
T
-->Ax=b
!--error 4
Niezdefiniowana zmienna: b
-->A=[1,1,1,-1;1,1,-1,1;2,1,-1,2;3,1,2,-1]
A =
1. 1. 1. - 1.
1. 1. - 1. 1.
2. 1. - 1. 2.
3. 1. 2. - 1.
-->b=[2,0,9]
b =
2. 0. 9.
-->Ax=b
Ax =
2. 0. 9.
-->x1=linsolve(A,-b)
!--error 5
Niezgodne wymiary kolumn/wierszy.
at line 9 of function linsolve called by :
x1=linsolve(A,-b)
-->b=[2,0,9]'
b =
2.
0.
9.
-->x1=linsolve(A,-b)
!--error 5
Niezgodne wymiary kolumn/wierszy.
at line 9 of function linsolve called by :
x1=linsolve(A,-b)
-->b=[2,0,9,7]'
b =
2.
0.
9.
7.
-->x1=linsolve(A,-b)
x1 =
- 5.
6.
15.
14.
-->A*x1-b
ans =
0.
3.553D-15
- 2.487D-14
- 8.882D-15
-->p1=norm(A*x1-b)
p1 =
2.665D-14
-->x2=inv(A)*b
x2 =
- 5.
6.
15.
14.
-->p2=norm(A*x2-b)
p2 =
1.376D-14
-->sA=sparse(A)
sA =
( 4, 4) sparse matrix
( 1, 1) 1.
( 1, 2) 1.
( 1, 3) 1.
( 1, 4) - 1.
( 2, 1) 1.
( 2, 2) 1.
( 2, 3) - 1.
( 2, 4) 1.
( 3, 1) 2.
( 3, 2) 1.
( 3, 3) - 1.
( 3, 4) 2.
( 4, 1) 3.
( 4, 2) 1.
( 4, 3) 2.
( 4, 4) - 1.
-->x3=lusolve(sA,b)
x3 =
- 5.
6.
15.
14.
-->x1
x1 =
- 5.
6.
15.
14.
-->x2
x2 =
- 5.
6.
15.
14.
-->x3
x3 =
- 5.
6.
15.
14.
-->A*x1-b
ans =
0.
3.553D-15
- 2.487D-14
- 8.882D-15
-->A*x2-b
ans =
10^(-13) *
0.0355271
0.0355271
0.0710543
0.1065814
-->A*x3-b
ans =
0.
0.
0.
0.
-->int32(x1)
ans =
-4
5
14
13
-->int32(x2)
ans =
-4
5
14
13
-->int32(x3)
ans =
-5
6
15
14
______________________________SCILAB_______________________
function y=f(x)
y=x^3-2*x^2-2*x+1
endfunction
funkcja fsolve()
[x[,v[,inf]]] = fsolve(x0,f[,jac[,tol]]) -->> to nie wyszło
x=-5:5
plot(x,f(x))
fsolve(-1.5,f)
fsolve([-1.5;0;2],f)
CWICZENIE:
function [f] = f2(x)
f(1)=x(1)^2+2)^2-50;
f(2)=x(1)*x(2)-25;
endfunction
Wyszukiwarka
Podobne podstrony:
Cw 28 05Cw 31 05Cw 29 05cw scilabcw scilabCw 27 05Cw 30 05ćw 05 podstawy programowaniaInstrukcja do ćw 05 Montaż modułu „wiercenia otworu” stanowiska dydaktycznego MPSacad cw 05 (2)ćw 34 Rozp Min Gosp 07 05 04Ćw 05 Funkcje paska „Warstwy”05 Komunikacja aplikacji z serwerem (cw)Ćw 05 Theveninwięcej podobnych podstron