Export a scaled graph to pdf for printing
Ältere Kommentare anzeigen
Hi all! very new to MATLAB here.
I have a code that plots a template for cutting exhaust pipe at user defined angles. I want to print out the curve, to scale, so I can cut it out and draw around pipe with it. For reference, the usual exhaust diameter is 63mm and cut angle 7 degrees.
The code works fine and gives the x and y axis in the correct units. However, from line 33 I am struggling. I have tried a few things, but the pdf will not print in cm, to scale. Any thoughts are greatly appreciated:
% pie cut template v1.2
% exports a printable template to pdf
clear all
close all
clc
d_pipe = input('Enter pipe outer diameter, (mm) ');
disp(d_pipe);
c_pipe = pi*d_pipe;
disp('pipe circumference (mm) ');
disp(c_pipe);
c_pipe_cm = c_pipe/10;
angle_cut = input('enter cutting angle (deg) ');
disp(angle_cut);
angle_cut_rad = angle_cut*pi/180;
amp_cm = d_pipe*tan(angle_cut_rad)/20;
x = linspace(-pi, pi, 1000);
x_cm = linspace(0,c_pipe_cm,1000);
y = amp_cm*cos(x)+amp_cm;
figure;
plot(x_cm, y, 'k', 'Linewidth', 3);
xlabel('Pipe circumference (cm)');
ylabel('Cutting template (cm)');
% title('Cutting template');
% graph limits for template
xlim([0, c_pipe_cm]);
% set figure size and position
width_cm = c_pipe_cm;
height_cm = amp_cm;
set(gcf, 'units', 'centimeters', 'position', [0, 0, width_cm, 5]);
% ensure pdf matches figure size
set(gcf, 'paperunits', 'centimeters');
set(gcf, 'papersize', [width_cm, height_cm]);
set(gcf, 'paperposition', [0, 0, width_cm, height_cm])
% export to pdf
print(gcf, 'Pipe template.pdf', '-dpdf', '-r300');
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!