<< Chapter < Page Chapter >> Page >
  • Cách1:

>>a=1;

>>b=-4;

>>c=5

>>x1=(-b+sqrt(b^2-4*a*c))/(2*a)

>>x2=(-b-sqrt(b^2-4*a*c))/(2*a)

  • Cách 2:

>>m=[a b c];

>>x=roots(m)

Hãy thay đổi các giá trị khác nhau của a, b và c tương ứng trong 2 cách giải trên. So sánh kết quả và nhận xét.

Giải phương trình x3- 2x2+4x+5=0. Kiểm chứng kết quả thu được bằng hàm polyval. Sinh viên có nhận xét gì về kết quả kiểm chứng.

Lặp lại câu  cho phương trình x7-2=0.

Sinh viên thử dùng hàm poly để tạo đa thức từ các nghiệm cho trước.

>>help poly

Đồ họa

Matlab hổ trợ chế độ đồ họa rất mạnh, bao gồm đồ họa 2D và 3D, với các trục tọa độ tuyến tính và phi tuyến bất kỳ.

Đồ họa 2 d

Đồ họa 2D chủ yếu dựa trên lệnh plot. Để được giúp đỡ, ta gõ:

>>help plot

Vẽ đồ thị hàm số y1=sinx.cos2x và hàm số y2=sinx2 trong [0-2], trên cùng hệ trục tọa độ, ta lần lượt thực hiện như sau:

>>x=0:0.01:2*pi;

>>y1=sin(x).*cos(2*x);%nhan tuong tung tung phan tu

>>plot(x,y1)

>>grid on%hien thi luoi

Sau khi thu được đồ thị hàm y1, để vẽ y2 trên cùng đồ thị, ta thực hiện:

>>hold on%giu hinh, mac nhien la hold off

>>y2=sin(x.^2);%luy thua tung phan tu

>>plot(x,y2,’k’)%duong ve co mau den

>>axis([0 4*pi –1.25 1.25])%dinh lai toa do hien thi

Ta có thể đặt nhãn cho các trục cũng như tiêu đề cho đồ thị:

>>xlabel(‘Time’)

>>ylabel(‘Amplitude’)

>>title(‘y1=sinx.cos2x and y2=sin(x^2)’)

>>legend(‘sinx.cos2x’,’sinx^2’)

Hình 1.1 – Biểu diễn đồ thị các hàm số trên cùng hệ trục tọa độ

Matlab hổ trợ rất nhiều thuộc tính đồ họa, để có thể kiểm soát các thuộc tính này ta cần dùng đến thẻ đồ họa. Ví dụ:

>>close all

>>x=[0 1 2 3];

>>y=[0 4 1 5];

>>h=plot(x,y)

h chính là thẻ đồ họa của hàm plot, để thấy các thuộc tính đồ hoạ, ta dùng lệnh:

>>set(h)

Bây giờ ta thử đặt một số thuộc tính đồ họa cho h.

>>set(h,’Color’, ‘r’)%dat lai mau do

>>set(h,'LineWidth',6)%dat do rong duong

>>set(h,'Marker','v','MarkerSize',6)

Hình 1.2 – Thay đổi thuộc tính đường biểu diễn

Dữ liệu dùng để vẽ được đặt trong ‘XData’ và ‘YData’.

>>set(h,'XData',[0 1 1 3])

>>set(h,'YData',[0 3 5 1])

Từ kết quả này, ta nhận thấy nếu dữ liệu trong ‘XData’ và ‘YData’ biến thiên theo thời gian, thì trên cửa sổ đồ họa (figure) ta sẽ thấy hình ảnh sinh động kiểu ‘animation’.

Hình 1.3 - Thay đổi dữ liệu trong cửa sổ đồ họa

Tương tự như hàm plot, sinh viên thử dùng các hàm semilogx, semilogy và loglog cho trường hợp trục tọa độ phi tuyến.

Ngoài các lệnh biểu diễn đường cong trong tọa độ Descartes, Matlab cũng hổ trợ việc vẽ đồ thị hàm số trong hệ tọa độ cực bằng hàm polar.

>>theta=0:0.05:2*pi;

>>r=sin(5*theta);

>>polar(theta,r)

Hình 1.4 – Biểu diễn đồ thị hàm số trong hệ tọa độ cực

Đồ họa 3 d

Matlab cung cấp nhiều hàm vẽ đồ thị 3D, chẳng hạn: plot3 - dùng để vẽ các đường trong không gian 3 chiều; mesh và surf - dùng để vẽ vật thể 3D (gõ help mesh và help surf để biết thêm các hàm 3D có liên quan).

Vẽ đồ thị 3D bằng hàm plot3:

>>t=0:pi/50:10*pi;

>>x=sin(t);

>>y=cos(t);

>>z=t;

>>subplot(121), plot3(x,y,z)%ve tren o thu nhat

>>grid on

>>subplot(122), plot3(x,y,t.^2)%ve tren o thu hai

>>grid on

Hình 1.5 – Vẽ đồ thị 3D bằng hàm plot3

Vẽ mặt paraboloid z=x2+y2 trong không gian 3 chiều:

>>close all

>>t=-5:0.1:5;

>>[x,y]=meshgrid(t);%dinh luoi ve

>>z=x.^2+y.^2;

>>subplot(2,2,1), mesh(z)%ve mat luoi 3D

>>title('mesh(z)')

>>subplot(2,2,2), meshc(z)%giong mesh nhung co them duong vien

>>title('meshc(z)')

>>subplot(2,2,3), meshz(z)%co them luoi tren mat x,y

>>title('meshz(z)')

>>subplot(2,2,4), waterfall(z)%chi ve luoi theo 1 huong

>>title('waterfall(z)')

***SORRY, THIS MEDIA TYPE IS NOT SUPPORTED.***

Hình 1.6 - Vẽ mặt paraboloid

Vẽ mặt z = sin x 2 + y 2 x 2 + y 2 size 12{z= { {"sin" left ( sqrt {x rSup { size 8{2} } +y rSup { size 8{2} } } right )} over { sqrt {x rSup { size 8{2} } +y rSup { size 8{2} } } } } } {} trong không gian 3 chiều:

>>x=-8:0.5:8;

>>y=x;

>>[x,y]=meshgrid(x,y);

>>r=sqrt(x.^2+y.^2);

>>z=sin(r)./r;

>>surf(x,y,z)

Hình 1.7 – Một biểu diễn đồ thị 3D khác

Sinh viên thử vẽ mặt trụ z = x 4 + y 2 size 12{z= sqrt {x rSup { size 8{4} } +y rSup { size 8{2} } } } {} bằng hàm mesh và hàm surf.

Tự chọn

Giải hệ phương trình sau:

2x1+4x2+6x3 – 2x4=0

x1+2x2+ x3 + 2x4=1

2x2+4x3 + 2x4=2

3x1- x2+ 10x4=10.

Chứng tỏ rằng (A+B)C=AC+BC, với:

A= 10 2 20 4 3 6 size 12{ left [ matrix { "10" {} # - 2 {} ##"20" {} # 4 {} ## 3 {} # 6{}} right ]} {} , B= 3 1 10 2 0 5 size 12{ left [ matrix { 3 {} # 1 {} ##- "10" {} # 2 {} ## 0 {} # 5{}} right ]} {} và C= 3 4 6 1 size 12{ left [ matrix { - 3 {} # 4 {} ##6 {} # 1{} } right ]} {} .

Sinh viên thử vẽ hình sau (Hình 1.8):

***SORRY, THIS MEDIA TYPE IS NOT SUPPORTED.***

(Hình 1.8)

Từ cửa sổ lệnh của Matlab, nhập: demos. Chọn MATLAB  Graphics  3D-plots. Chạy chương trình demo này.

Questions & Answers

it is the relatively stable flow of income
Chidubem Reply
what is circular flow of income
Divine Reply
branches of macroeconomics
SHEDRACK Reply
what is Flexible exchang rate?
poudel Reply
is gdp a reliable measurement of wealth
Atega Reply
introduction to econometrics
Husseini Reply
Hi
mostafa
hi
LEMLEM
hello
Sammol
hi
Mahesh
bi
Ruqayat
hi
Ruqayat
Hi fellas
Nyawa
hey
Sammol
hi
God
hello
Jahara
Good morning
Jorge
hi
abubakar
hi
Nmesoma
hi
Mahesh
Hi
Tom
Why is unemployment rate never zero at full employment?
Priyanka Reply
bcoz of existence of frictional unemployment in our economy.
Umashankar
what is flexible exchang rate?
poudel
due to existence of the pple with disabilities
Abdulraufu
the demand of a good rises, causing the demand for another good to fall
Rushawn Reply
is it possible to leave every good at the same level
Joseph
I don't think so. because check it, if the demand for chicken increases, people will no longer consume fish like they used to causing a fall in the demand for fish
Anuolu
is not really possible to let the value of a goods to be same at the same time.....
Salome
Suppose the inflation rate is 6%, does it mean that all the goods you purchase will cost 6% more than previous year? Provide with reasoning.
Geetha Reply
Not necessarily. To measure the inflation rate economists normally use an averaged price index of a basket of certain goods. So if you purchase goods included in the basket, you will notice that you pay 6% more, otherwise not necessarily.
Waeth
discus major problems of macroeconomics
Alii Reply
what is the problem of macroeconomics
Yoal
Economic growth Stable prices and low unemployment
Ephraim
explain inflationcause and itis degre
Miresa Reply
what is inflation
Getu
increase in general price levels
WEETO
Good day How do I calculate this question: C= 100+5yd G= 2000 T= 2000 I(planned)=200. Suppose the actual output is 3000. What is the level of planned expenditures at this level of output?
Chisomo Reply
how to calculate actual output?
Chisomo
how to calculate the equilibrium income
Beshir
Criteria for determining money supply
Thapase Reply
who we can define macroeconomics in one line
Muhammad
Aggregate demand
Mohammed
C=k100 +9y and i=k50.calculate the equilibrium level of output
Mercy Reply
Hi
Isiaka
Hi
Geli
hy
Man
👋
Bahunda
hy how are you?
Man
ys
Amisha
how are you guys
Sekou
f9 guys
Amisha
how are you guys
Sekou
ys am also fine
Amisha
fine and you guys
Geli
from Nepal
Amisha
nawalparasi district from belatari
Amisha
nd u
Amisha
I am Camara from Guinea west Africa... happy to meet you guys here
Sekou
ma management ho
Amisha
ahile becheclor ho
Amisha
hjr ktm bta ho ani k kaam grnu hunxa tw
Amisha
belatari
Amisha
1st year ho
Amisha
nd u
Amisha
ahh
Amisha
kaha biratnagar
Amisha
ys
Amisha
kina k vo
Amisha
money as unit of account means what?
Kalombe
A unit of account is something that can be used to value goods and services and make calculations
Jim
all of you please speak in English I can't understand you're language
Muhammad
I want to know how can we define macroeconomics in one line
Muhammad
it must be .9 or 0.9 no Mpc is greater than 1 Y=100+.9Y+50 Y-.9Y=150 0.1Y/0.1=150/0.1 Y=1500
Kalombe
Mercy is it clear?😋
Kalombe
hi can someone help me on this question If a negative shocks shifts the IS curve to the left, what type of policy do you suggest so as to stabilize the level of output? discuss your answer using appropriate graph.
Galge Reply
if interest rate is increased this will will reduce the level of income shifting the curve to the left ◀️
Kalombe
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Thí nghiệm cad (computer-aided design). OpenStax CNX. Jul 29, 2009 Download for free at http://cnx.org/content/col10797/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Thí nghiệm cad (computer-aided design)' conversation and receive update notifications?

Ask