Docsity

Plotting Function - Matlab Code, Study Guides, Projects, Research of Computer Programming

Toggle sidebar
bg1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plotting
x = [0 1 2 3 4]; % Basic plotting
plot(x); % Plot x versus its index values
pause % Wait for key press
plot(x, 2*x); % Plot 2*x versus x
axis([0 8 0 8]); % Adjust visible rectangle
figure; % Open new figure
x = pi*[-24:24]/24;
plot(x, sin(x));
xlabel('radians'); % Assign label for x-axis
ylabel('sin value'); % Assign label for y-axis
title('dummy'); % Assign plot title
figure;
subplot(1, 2, 1); % Multiple functions in separate graphs
plot(x, sin(x)); % (see "help subplot")
axis square; % Make visible area square
subplot(1, 2, 2);
plot(x, 2*cos(x));
axis square;
figure;
plot(x, sin(x));
hold on; % Multiple functions in single graph
plot(x, 2*cos(x), '--'); % '--' chooses different line pattern
legend('sin', 'cos'); % Assigns names to each plot
hold off; % Stop putting multiple figures in current
% graph
figure; % Matrices vs. images
m = rand(64,64);
imagesc(m) % Plot matrix as image
colormap gray; % Choose gray level colormap
axis image; % Show pixel coordinates as axes
axis off; % Remove axes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
๎˜ƒ
docsity.com

Partial preview of the text

Download Plotting Function - Matlab Code and more Study Guides, Projects, Research Computer Programming in PDF only on Docsity!

% Plotting

x = [0 1 2 3 4]; % Basic plotting plot(x); % Plot x versus its index values pause % Wait for key press plot(x, 2x); % Plot 2x versus x axis([0 8 0 8]); % Adjust visible rectangle

figure; % Open new figure x = pi*[-24:24]/24; plot(x, sin(x)); xlabel('radians'); % Assign label for x-axis ylabel('sin value'); % Assign label for y-axis title('dummy'); % Assign plot title

figure; subplot(1, 2, 1); % Multiple functions in separate graphs plot(x, sin(x)); % (see "help subplot") axis square; % Make visible area square subplot(1, 2, 2); plot(x, 2*cos(x)); axis square;

figure; plot(x, sin(x)); hold on; % Multiple functions in single graph plot(x, 2*cos(x), '--'); % '--' chooses different line pattern

legend('sin', 'cos'); % Assigns names to each plot hold off; % Stop putting multiple figures in current % graph

figure; % Matrices vs. images

m = rand(64,64); imagesc(m) % Plot matrix as image colormap gray; % Choose gray level colormap axis image; % Show pixel coordinates as axes axis off; % Remove axes

docsity.com