用matlab怎么输出变量,matlab – 如何从变量手动输出发布内容

要使用工作区中的变量

当使用带有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,'

'])

产量

上面的代码生成以下代码:

115aff8ff863c69528ad5ea46ad1c1ec.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值