Can anyone help me with these matlab questions with ‘fplot’ not ‘ezplot’

Can anyone help me with these matlab questions with ‘fplot’ not ‘ezplot’?

The Correct Answer and Explanation is:

Certainly! Here’s how you can answer all parts of Question 13 using MATLAB’s fplot and fimplicit functions (modern alternatives to ezplot), along with a 300-word explanation.


MATLAB Code Using fimplicit and fplot:

% Part (a)
figure;
fimplicit(@(x, y) 3*y + y.^3 - x.^3 - 5, [-3, 3, -3, 3]);
title('Part (a): Curve of 3y + y^3 - x^3 = 5');
xlabel('x'); ylabel('y'); grid on;

% Part (b)
figure;
hold on;
levels = [-2, 0, 2, 5, 8];
for c = levels
    fimplicit(@(x, y) 3*y + y.^3 - x.^3 - c, [-3, 3, -3, 3]);
end
title('Part (b): Level Curves of 3y + y^3 - x^3');
xlabel('x'); ylabel('y'); grid on;
legend(arrayfun(@(c) sprintf('Level = %d', c), levels, 'UniformOutput', false));
hold off;

% Part (c)
figure;
C = 1*log(1) + 1*log(1); % f(1,1)
fimplicit(@(x, y) y.*log(x) + x.*log(y) - C, [0.1, 3, 0.1, 3]);
title('Part (c): Level Curve of f(x, y) = ylnx + xlny through (1,1)');
xlabel('x'); ylabel('y'); grid on;

Explanation

In MATLAB, fplot is typically used to plot functions of a single variable, while fimplicit is more suitable for plotting implicit equations like those given in this problem. We use fimplicit for all parts of this question because each involves a curve or level set described by an implicit function of x and y.

Part (a): We plot the implicit equation 3y+y3−x3=53y + y^3 – x^3 = 5 by rewriting it as 3y+y3−x3−5=03y + y^3 – x^3 – 5 = 0. The fimplicit function interprets this as the zero level set of a function and plots the corresponding curve over a specified domain.

Part (b): To plot level curves of the function f(x,y)=3y+y3−x3f(x, y) = 3y + y^3 – x^3 for several values (−2, 0, 2, 5, 8), we loop through each level cc and plot the curve f(x,y)−c=0f(x, y) – c = 0, i.e., 3y+y3−x3−c=03y + y^3 – x^3 – c = 0. We use hold on to overlay all curves in one figure and add a legend for clarity.

Part (c): The function f(x,y)=yln⁡x+xln⁡yf(x, y) = y \ln x + x \ln y is implicit in both variables. We calculate the function value at (1, 1), which is 0, since ln⁡(1)=0\ln(1) = 0. Then we plot the level curve yln⁡x+xln⁡y=0y \ln x + x \ln y = 0 as f(x,y)−C=0f(x, y) – C = 0, with C = 0.

This approach using fimplicit provides more control, modern syntax, and greater flexibility than the deprecated

.

Scroll to Top