필터 지우기
필터 지우기

loop explanation applied in equations solution

조회 수: 1 (최근 30일)
Michael
Michael 2023년 4월 29일
답변: Neha 2023년 5월 3일
Hi
I currently learning to solve math equations using matlab.Could you explain me the loop below?
thanks
while check~='y'
x0y0=input(['Dwse mou ta akraia shmeia ths grafikhs parastashs\n ' ...
'sth morfh [x0 xend y0 yend] : ']);
xstart=x0y0(1);xend=x0y0(2);ystart=x0y0(3);yend=x0y0(4);
e=10^(-14);
x=linspace(xstart,xend,60);
y=linspace(ystart,yend,60);
[X,Y]=meshgrid(x,y);
Z1=f(X,Y);
Z2=g(X,Y);
contour(X,Y,Z1,[0 0],'m')
hold on
contour(X,Y,Z2,[0 0],'b')
hold off
check=input('Eisai euxaristhmenos apo th grafikh parastash?','s');
end

답변 (1개)

Neha
Neha 2023년 5월 3일
The code creates a while loop that allows the user to input the boundaries of a graphical representation of a mathematical function and plot it with contours.
Inside the while loop, the input values are assigned to variables 'xstart', 'xend', 'ystart', and 'yend'.
The 'linspace' function is used to create a vector x of 60 equally spaced points between 'xstart' and 'xend', and a vector y of 60 equally spaced points between 'ystart' and 'yend'.
The 'meshgrid' function returns 2-D grid coordinates based on the coordinates contained in vectors x and y. X is a matrix where each row is a copy of x, and Y is a matrix where each column is a copy of y. The grid represented by the coordinates X and Y has length(y) rows and length(x) columns.
After f and g functions return Z1 and Z2, the 'contour' function is used to plot the contour lines of Z1 and Z2 where the contour level is 0 (contour lines are drawn at a single height- 0).
The 'm' and 'b' arguments specify the colors of the contour lines.
For detailed explanation about contour' and 'meshgrid' functions, please refer to the following documentation:

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by