Matlab错误:未为“单元格"输入定义功能 [英] Matlab Error: Function is not defined for 'cell' inputs

查看:149
本文介绍了Matlab错误:未为“单元格"输入定义功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

fid = fopen('./tickers.tex', 'wt+');
for x = 1 : size(C.names,1) 
    fprintf(fid, '%s & ', C.names(x,1:end-1)); 
    fprintf(fid, '%s \\\\ \t\n', C.names(x,end)); 
end 
fclose(fid);

这为什么会给我错误:

使用fprintf时出错 没有为单元格"输入定义功能.

Error using fprintf Function is not defined for 'cell' inputs.

这确实可行:

fprintf(' %f    ', D{:});

我在理解基本的matlab数据类型时遇到困难.谁能像最后一种语法一样为我提供一种打印单元格数组的解决方案?

I'm having difficulties understanding basic matlab datatypes. Could anyone provide me with a solution to print the cell array just like the last syntax?

推荐答案

好吧,我假设C是一个单元格数组,并且您希望从C的每个条目中打印一些字符串.您的代码不正确. 试试这个:

Ok from the error and code you have I am assuming C is an array of cells and you want to print some string from each entry of C. Assuming this, your code is incorrect. Try this:

fid = fopen('./tickers.tex', 'wt+');
for x = 1 : size(C,1) 
    fprintf(fid, '%s & ', C{x}.names(1:end-1)); 
    fprintf(fid, '%s \\\\ \t\n', C{x}.names(end)); 
end 
fclose(fid);

这是您想要的吗?如果没有,请提供有关C的更多信息

Is this what you want? If not please provide more information about C

这篇关于Matlab错误:未为“单元格"输入定义功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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