Published File does not display Figure/Graph in PDF
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am attempting to auto-publish a document after entering in some user driven values for a script I wrote, but it seems like I can't get the figure to display in the output. It generates the pdf in the HTML folder (which would be great to move it to the root I am working in and not use the HTML folder) but doesn't hold the figure.
The discrete values I am using (as an examply are as follow:
Tension Force Allowed (lbf) = 1092
Shear Force Allowed (lbf) = 655
Shear Force Given (lbf) = 215
Your result should be the following
Maximum Tension given Stress is 1072.52 lbs

clc; clear; close all;
disp('Shear vs Tension Interaction Curve')
disp(' ');
% Shear and Tension discrete and calculated values
t = input('Tension Force Allowed (lbf) = '); % Prompt for max Tension
s = input('Shear Force Allowed (lbf) = '); % Prompt for max Shear
S = input('Shear Force Given (lbf) = '); % Prompt for actual shear
T = ((1-(S.^3)/(s.^3)).*t.^2).^(.5); % Calculate derated tension allowed
% Define Plot
x = 0:s; y = ((1-(x.^3)/(s.^3)).*t.^2).^(.5);
plot(x,y); axis([0 s+s*.1 0 t+t*.1])
grid on;
hold on;
xline = linspace(0,S);
yline = linspace(0,T);
plot (xline,yline)
% Display derated value and label on plot
fprintf('\nMaximum Tension given Stress is %4.2f lbs\n', T)
str = ['(',num2str(S,5),' , ', num2str(T,5),')'];
text(S+20,T+20,str)
disp(' ');
options.codeToEvaluate = 'c = 1; T_S_Interaction(c)';
options.format = 'pdf';
publish('T_S_Interaction.m', options);
0 Commenti
Risposte (1)
Abhipsa
il 2 Apr 2025
I understand that you want to automatically publish your MATLAB script and ensure that the output image appears in the published script. Additionally, you want the published script to be saved in your working directory rather than the default "html" directory.
The publish function in MATLAB does not support input, so user driven values cannot be used in a script that needs to be published.
You can refer to the below link for more details about publish function’s limitations:
If the MATLAB file given as input to publish runs successfully, then the output image will also be captured in the published report.
To save the published document in your desired output directory, you can use the “outputDir” property of the “options” structure. For example, to set the output directory as the current working directory, use:
options.outputDir = ‘.’;
You can use the following command to learn more about publish function:
>> doc publish
Starting from MATLAB R2025a, there is an option to save Live Script (.mlx) files in a new plain-text Live Code file format (.m). After saving an .mlx file as an .m file, you can use the "Export" option to convert the script into the desired file format and save it in the desired location. This exported file will also include the generated output images, and user-driven inputs can be used.
You can refer to the below link for more details:https://www.mathworks.com/help/releases/R2025a/matlab/matlab_prog/plain-text-file-format-for-live-scripts.html
I hope you will find this helpful.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!