How can I graph an equation with 'changing constant' values?

4 ビュー (過去 30 日間)
A
A 2014 年 10 月 11 日
コメント済み: A 2014 年 10 月 11 日
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!

採用された回答

Rick Rosson
Rick Rosson 2014 年 10 月 11 日
Equation = @(x,y) Constant + 10 + 90*(x>=3) + 900*(x>=6) + 5.*x + 5.*y;
  1 件のコメント
A
A 2014 年 10 月 11 日
This works. Thank you.

サインインしてコメントする。

その他の回答 (1 件)

Azzi Abdelmalek
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)
  2 件のコメント
A
A 2014 年 10 月 11 日
Thanks for your response.
What is heaviside???
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 10 月 11 日

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by