How to include functions in Matlab Notebook?

조회 수: 10 (최근 30일)
Richard Startz
Richard Startz 2012년 11월 27일
답변: cheng chen 2017년 3월 14일
I suspect there's an obvious answer to this, but if I want to include function definitions in a Matlab Notebook (so the documentation is in Word) how do I do that? Perhaps someone can point me to the spot I've missed in the Matlab documents. Thanks.

답변 (3개)

Image Analyst
Image Analyst 2012년 11월 27일
You mean like the "Publish" functionality? In R2012b there is a "Publish" tab if you're in the editor window. Publish existed in earlier versions too - look it up in your help.
  댓글 수: 1
Richard Startz
Richard Startz 2012년 11월 27일
I don't think that's what I want, but I probably didn't ask clearly. I want to make up homework answers for my students. In the past, that would have been one or more Matlab functions with documentation written in. Instead, I'd like to "embed" the Matlab code in Word so that it's easier to write explanations of what I'm doing. The code often includes function definitions.

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


Sean de Wolski
Sean de Wolski 2012년 11월 27일
Hi Richard,
I don't believe it is possible to include a function definition in a notebook (though not positive).
What you could do as a workaround is have the function defined in MATLAB and then call
type foo
To have the contents of the function printed.
@IA, Here is some more info on Notebooks. I hadn't learned about them until recently either...
They're pretty cool actually; it's a way that you can evaluate code in Word and have the results printed right it your word doc.

cheng chen
cheng chen 2017년 3월 14일
your matlab "current directory" must include the function what you difined.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by