要使用工作区中的变量
当使用带有html编码字符串的disp()发布到html时,会将行添加到输出中(不使用代码输出的格式).
例如
str = sprintf('some value: %f from the workspace',variable)
disp(['',str,''])
笔记:
>它非常敏感,你可能需要在它们之间添加不可见的分节符
代码输出和以这种方式生成的行.
>添加段落标记有助于改进格式
>可悲的是(据我所知)出版降价解释器没有在这些线上使用,它们被“注入”输出,因此乳胶方程式不起作用.
码
%% HTML option
% This option is anly available with HTML output...
a=1;
str = ['The current value of a is ', num2str(a)];
%%%
%
% When publishing to HTML using the |disp| function with HTML tags
% surrounding the string can allow workspace variables to appear within
% text.
%
% For example the following line is created by evaluating code, it is not a
% comment in the m-file
%
disp(['
',str,'
']);%% Changing the value
% Now if we change a to 2...
a=2,str = ['The new value of a is ', num2str(a)];
%%
% Re-runing a similar code should show the updated value
disp(['
',str,'
'])产量
上面的代码生成以下代码: