0% found this document useful (0 votes)
8 views4 pages

Lab Practice

The document contains MATLAB code for generating various plots including a scatter plot, 3D line plot, surface plot, contour plot, mesh plot, filled contour plot, waterfall plot, and a histogram. It uses a bird image and defines a mathematical function Z based on X and Y coordinates. The plots are organized in a 3x3 grid layout for visualization.

Uploaded by

Haronamery
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Lab Practice

The document contains MATLAB code for generating various plots including a scatter plot, 3D line plot, surface plot, contour plot, mesh plot, filled contour plot, waterfall plot, and a histogram. It uses a bird image and defines a mathematical function Z based on X and Y coordinates. The plots are organized in a 3x3 grid layout for visualization.

Uploaded by

Haronamery
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Name : khlood Alqahtani ID : 443811964

% Define x and y properly


x = linspace(0, 10, 100);
y = linspace(0, 10, 100);
[X, Y] = meshgrid(x, y);
Z = X .* exp(-(X.^2 + Y.^2)); % Define Z correctly
figure;

img = imread('bird.jpg');
subplot(3,3,1); % Use a 3x3 grid
imshow(img);
title('Bird Image');
axis on;

% Scatter plot
subplot(3,3,2);
scatter(x, sin(x));
xlabel('X values');
ylabel('sin(X)');
title('Scatter Plot');

% 3D Scatter plot alternative using plot3

z = x;
subplot(3,3,3);
plot3(x, y(1:length(x)), z, 'r');
grid on;
xlabel('X');
ylabel('Y');
zlabel('Z');
title('3D Line Plot');
% Surface plot
subplot(3,3,4);
surf(X, Y, Z);
shading interp;
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Surface Plot');

% Contour plot
subplot(3,3,5);
contour(X, Y, Z);
xlabel('X');
ylabel('Y');
title('Contour Plot');

% Mesh plot
subplot(3,3,6);
mesh(X, Y, Z);
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Mesh Plot');

% Filled contour plot

subplot(3,3,7);
contourf(X, Y, Z, 20);
colorbar;
xlabel('X');
ylabel('Y');
title('Filled Contour Plot');

% Waterfall plot

subplot(3,3,8);
waterfall(X, Y, Z);
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Waterfall Plot');

% Histogram for visualizing Z values


subplot(3,3,9);
histogram(Z(:), 50);
xlabel('Z values');
ylabel('Frequency');
title('Z Distribution');

You might also like