如何将DISP的结果作为返回参数转换为变量? [英] How to get result of DISP as return parameter into a variable?

查看:102
本文介绍了如何将DISP的结果作为返回参数转换为变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

函数dispdisplay都没有返回参数,并且 在命令窗口中显示变量内容.

Both functions disp and display do not have return parameters and display variable content into command window.

我想将函数调用的结果(显示的字符串)放入一个 变量而不是输出到命令窗口,就像这样的str = ToString( myStruct );,其中输入变量是MATLAB结构!

I would like to get the result of function call (displayed string) into a variable instead of output into command window, something like this str = ToString( myStruct ); where input variable is a MATLAB struct!

我知道显示结果取决于命令窗口的可用宽度,它可以宽也可以窄.

I am aware that display result depends on available width of command window, it can be either wide or narrow.

在所有现代编程语言中,它都是obj.ToString()方法.

In all modern programming languages it would be a obj.ToString() method.

推荐答案

toString = @(x) evalc('disp(x)')

不太漂亮,但是应该可以完成工作.

Not pretty, but it should get the job done.

这篇关于如何将DISP的结果作为返回参数转换为变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆