How can I graph an equation with 'changing constant' values?
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi,
I have a relatively straightforward question: How can I graph a surface with a changing 'constant' value depending on what the 'x' value is?
x = [-10:10];
y = [-10:10];
Constant = 5;
Equation = @(x,y) Constant + 5.*x + 5.*y;
%
where:
Constant = Constant + 10 for x < 3
Constant = Constant + 100 for x >= 3 > 6
Constant = Constant + 1000 for x >= 6
%
Thank you!
댓글 수: 0
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2014년 10월 11일
편집: Azzi Abdelmalek
2014년 10월 11일
Edit
x = [-10:0.1:10];
y = [-10:0.1:10];
Constant = 5+10*not(heaviside(x-3))+100*(heaviside(x-3)-heaviside(x-6))+1000*heaviside(x-6);
Equation = @(x,y,Constant) Constant + 5.*x + 5.*y;
z=Equation(x,y,Constant)
plot3(x,y,z)
%Or
x = [-10:0.1:10];
y = [-10:0.1:10];
Constant= 5+10*(x<3)+100*(x>=3 & x<6)+1000*(x>=6)
Equation = @(x,y,Constant) Constant + 5.*x + 5.*y;
z=Equation(x,y,Constant)
plot3(x,y,z)
참고 항목
카테고리
Help Center 및 File Exchange에서 Construction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!