Diana
Diana

Reputation: 363

When using the function PUBLISH in matlab, how do I print the answer of each of command under the specific command?

For example, let's say I have the following commands

a= [ 1 2 4 ];
length(a)
sum(a)

When I use publish I want to have the following:

length(a)

ans = 
3

sum(a)

ans = 
7

Right now, I have the commands first and then the answers.

Upvotes: 0

Views: 28

Answers (1)

Adiel
Adiel

Reputation: 3071

On publish, the answers shown for each code section.

To insert a new code section, use %% like that:

a = [1 2 4];
length(a)
%%
sum(a)

So in file the answers will separated:

enter image description here

Upvotes: 3

Related Questions