[x, y] = meshgrid(-pi:0.1:pi, -pi: 0.1:pi); % Define two functions z1 = sin(x) * cos(y); z2 = cos(x) .* sin(y); figure; % Plot the overlayed contours subplot(1,3,1) contour(x, y, z1, 20, 'LineColor', 'b'); % 20 contour lines, blue color hold on; contour(x, y, z2, 20, '--', 'LineColor', 'r'); % 20 contour lines, red color, dashed % Plot the second contour with different line style and color % Add labels and legend title('Overlayed Contour Plot of Two Functions'); legend('sin(x) * cos(y)', 'cos(x) * sin(y)'); hold off; subplot(1,3,2) contourf(x, y, z1, 20, '--', 'LineColor', 'b'); % 20 contour lines, blue color, dashed % Add labels and legend title('Filled Contour of Function 1'); legend('sin(x) * cos(y)'); colorbar; subplot(1,3,3) contourf(x, y, z2, 20, % Add labels and legend 'LineColor', 'r'); % 20 contour lines, red color, dashed title('Filled Contour of Function 2'); legend('cos(x) * sin(y)'); colorbar; Question 1. What type of data format is suitable for contour plotting? Question 2. Please provide two engineering examples that contour plotting is most appropriate for. Please include rationales for your choice.

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter16: Graphics
Section: Chapter Questions
Problem 17RQ
Question

Answer the question using matlab and show your steps & work

[x, y]
=
meshgrid(-pi:0.1:pi, -pi: 0.1:pi);
% Define two functions
z1 = sin(x) * cos(y);
z2 = cos(x) .* sin(y);
figure;
% Plot the overlayed contours
subplot(1,3,1)
contour(x, y, z1, 20, 'LineColor', 'b'); % 20 contour lines, blue color
hold on;
contour(x, y, z2, 20, '--', 'LineColor', 'r'); % 20 contour lines, red color, dashed
% Plot the second contour with different line style and color
% Add labels and legend
title('Overlayed Contour Plot of Two Functions');
legend('sin(x) * cos(y)', 'cos(x) * sin(y)');
hold off;
subplot(1,3,2)
contourf(x, y, z1, 20, '--', 'LineColor', 'b'); % 20 contour lines, blue color, dashed
% Add labels and legend
title('Filled Contour of Function 1');
legend('sin(x) * cos(y)');
colorbar;
subplot(1,3,3)
contourf(x, y, z2, 20,
% Add labels and legend
'LineColor', 'r'); % 20 contour lines, red color, dashed
title('Filled Contour of Function 2');
legend('cos(x) * sin(y)');
colorbar;
Question 1. What type of data format is suitable for contour plotting?
Question 2. Please provide two engineering examples that contour plotting is most appropriate for. Please
include rationales for your choice.
Transcribed Image Text:[x, y] = meshgrid(-pi:0.1:pi, -pi: 0.1:pi); % Define two functions z1 = sin(x) * cos(y); z2 = cos(x) .* sin(y); figure; % Plot the overlayed contours subplot(1,3,1) contour(x, y, z1, 20, 'LineColor', 'b'); % 20 contour lines, blue color hold on; contour(x, y, z2, 20, '--', 'LineColor', 'r'); % 20 contour lines, red color, dashed % Plot the second contour with different line style and color % Add labels and legend title('Overlayed Contour Plot of Two Functions'); legend('sin(x) * cos(y)', 'cos(x) * sin(y)'); hold off; subplot(1,3,2) contourf(x, y, z1, 20, '--', 'LineColor', 'b'); % 20 contour lines, blue color, dashed % Add labels and legend title('Filled Contour of Function 1'); legend('sin(x) * cos(y)'); colorbar; subplot(1,3,3) contourf(x, y, z2, 20, % Add labels and legend 'LineColor', 'r'); % 20 contour lines, red color, dashed title('Filled Contour of Function 2'); legend('cos(x) * sin(y)'); colorbar; Question 1. What type of data format is suitable for contour plotting? Question 2. Please provide two engineering examples that contour plotting is most appropriate for. Please include rationales for your choice.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,