フィルターのクリア

I can't sketch this function

1 回表示 (過去 30 日間)
Le Truong
Le Truong 2022 年 5 月 15 日
回答済み: Ishan Gupta 2022 年 7 月 27 日
As the title, my function can't be sketched and i don't know which code replace surf() to get it works.
the function: f = x^2+y^2+x*y-12*log(x)-10*log(y)
clc; % Clear the command window.
fprintf('Beginning to run %s.m ...\n', mfilename);
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
xMin = -20;
xMax = 20;
yMin = -10;
yMax = 10;
numPoints = 1000;
[x, y] = meshgrid(linspace(xMin, xMax, numPoints), linspace(xMin, xMax, numPoints));
f = x .^ 2 + x .* y + y .^ 2 - 12*log(x) - 10*log(y);
surf(x, y, f, 'EdgeColor', 'none');
grid on;
title('f(x, y) = x .^ 2 + x .* y + y .^ 2', 'FontSize', fontSize, 'Interpreter', 'none');
xlabel('x', 'FontSize', fontSize);
ylabel('y', 'FontSize', fontSize);
zlabel('f(x, y)', 'FontSize', fontSize);
fprintf('Done running %s.m\n', mfilename);
  2 件のコメント
Torsten
Torsten 2022 年 5 月 15 日
Do you know what happens if you take the log of a negative number ?
Le Truong
Le Truong 2022 年 5 月 16 日
Oh thanks, i will fix my code right away.

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

回答 (1 件)

Ishan Gupta
Ishan Gupta 2022 年 7 月 27 日
You should first check and remove negative values from the input to log

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by