Hi I want to plot a graph of Z=sin (x) cos(y) , y<3 and x>-3 but I'm unsure on how to code the range. Any help is much appreciated !

11 ビュー (過去 30 日間)
usserio
usserio 2018 年 1 月 25 日
回答済み: Star Strider 2018 年 1 月 25 日
I understand that we usually assign a numerical value when assigning the range for x and y but I'm just unsure of how to process when it's x less than a certain value vs when x is equal or less than a value ( which I know how to do). Sorry if the explaination is confusing, I'm still new to matlab

回答 (1 件)

Star Strider
Star Strider 2018 年 1 月 25 日
Try this:
z = @(x,y) sin(x).*cos(y) .* ((x>-3) & (y<3));
[X,Y] = meshgrid(-5:0.5:5);
figure(1)
surf(X, Y, z(X,Y))
xlabel('\bfX')
ylabel('\bfY')
grid on

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by