Exporting MATLAB code to word file

조회 수: 1,071 (최근 30일)
Sakshi
Sakshi 2011년 8월 11일
댓글: Walter Roberson 2024년 11월 22일 22:14
I want to export my MATLAB code in word file. If I opt for print command directly, the code is getting printed, but the vertical lines that connect the start and end of a loop are not getting shown. For example,
for d=1:s
fraction(d)=vert(d)/add;
if(d==1)
cumulative(d)=fraction(d);
continue
end
cumulative(d)=cumulative(d-1)+fraction(d)
end
The vertical line connecting the For loop with its corresponding end is not appearing. Any suggestions how I can do that ?
  댓글 수: 1
Pedro Rodenas
Pedro Rodenas 2016년 10월 17일
You can export your code to HTML using the function publish(file), and later copy the text in HTML file

댓글을 달려면 로그인하십시오.

답변 (4개)

Chirag Gupta
Chirag Gupta 2011년 8월 11일
You can use the publish command to publish the code and the results in a neat manner directly to word, however this will also not show the "line".
This "line" is the MATLAB editor's graphical line to ease with writing and navigating code and as such cannot be navigated to word. The easiest way to to do so is to do Print Screen and cut the relevant image (in Win 7, you can directly use the Windows snipping tool).
  댓글 수: 1
Sakshi
Sakshi 2011년 8월 11일
Thanks Chirag. Yeah I had published it earlier but I wanted the lines. I have actually seen some reports with the lines and I doubt if they used printscreen for the same. But anyway, thank you for answering !

댓글을 달려면 로그인하십시오.


Tanveer Hussain
Tanveer Hussain 2022년 11월 6일
Brother simplest method is that convert directly into pdf by "ctrl+p" then convert pdf into word.
  댓글 수: 2
John D'Errico
John D'Errico 2022년 11월 6일
And as others have said, that does not solve the problem.
Tanveer Hussain
Tanveer Hussain 2022년 11월 6일
Thanks for more details
brother go to the print function in the matlab you can see the various options for the text setting
1) you can chnage the font setting
2)change the stlye
3) export to pdf, microsoft and xps etc
After converting into pdf you can directly convert into word format.

댓글을 달려면 로그인하십시오.


Wedi
Wedi 2024년 9월 27일
% MATLAB Script for Fourier Series Approximation
% Parameters
L = 1; % Half-period
N = 10; % Number of harmonics
t = linspace(-L, L, 1000); % Time vector
f_exact = L - abs(t); % Actual function
% Initialize Fourier series approximation
a0 = L / 2; % Constant term
f_approx = a0 * ones(size(t)); % Start with the constant term
% Calculate Fourier coefficients and build the approximation
an = zeros(1, N); % Coefficients for cosine
bn = zeros(1, N); % Coefficients for sine
for n = 1:N
% Calculate coefficients (example values; replace with actual calculations)
an(n) = 0; % For f(t) = L - |t|, a_n is 0
bn(n) = (2 * L / (n * pi)) * (1 - (-1)^n); % Example for sine coefficients
f_approx = f_approx + an(n) * cos(n * pi * t / L) + bn(n) * sin(n * pi * t / L);
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2024년 11월 22일 22:10
I do not understand how this answers the question that was asked?

댓글을 달려면 로그인하십시오.


Thisara
Thisara 2024년 11월 22일 9:17
how to save the output of command window in matlab as a picture
  댓글 수: 1
Walter Roberson
Walter Roberson 2024년 11월 22일 22:14
If you right-click on the command window, and select Print then it brings up a dialog for printing as far back as your scrolling goes . The amount that your scrolling window goes is affected by Preferences -> Command Window -> Number of lines in command window scroll buffer

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by