string matlab:将字符数组转换为字符串

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13397681/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 01:42:54  来源:igfitidea点击:

matlab: convert char array into string

arraysstringmatlab

提问by user1822048

I implemented a bash script in matlab, which returns a char array with all the outputs (echo). Now I would like to use the data stored in the array, to open a file. Unfortunately, I don't know how to convert the array into a string. The following code works:

我在 matlab 中实现了一个 bash 脚本,它返回一个带有所有输出(回声)的字符数组。现在我想使用存储在数组中的数据来打开一个文件。不幸的是,我不知道如何将数组转换为字符串。以下代码有效:

[status, output] = system('./script.sh', '-echo');
filename = [ output(1) output(2) output(3) output(4) output(5) output (6) ];

But it is not very convenient and doesn't allow different lengths of the filename. Is there an easy way to solve this?

但它不是很方便,并且不允许不同长度的文件名。有没有简单的方法来解决这个问题?

回答by Rody Oldenhuis

Basically, character arrays arestrings; there's no need to convert them.

基本上,字符数组字符串;没有必要转换它们。

filename = output

should do the trick.

应该做的伎俩。