我是靠谱客的博主 花痴飞鸟,最近开发中收集的这篇文章主要介绍c# 调matlab传字符串,我如何传递一个字符串作为一个MATLAB函数参数?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Basically, I have 10 data files and I wrote a MATLAB function to process these data.

The code is like this:

function Z = fitdata(file_path)

A = importdata(file_path,',');

...

end

Since I don't want to input the same command 10 times (for different file names), I wrote another script to automate this processing. The code looks like this:

function X = automate()

myarray = {'file_one', 'file_two', 'file_three',......,'file_ten'};

for i = 1:9

mypath = myarray{i};

W = fitdata(mypath);

...

end

end

But I'm getting the error "Too many input arguments" at the call to the fitdata(file_path) function.

How should I do this?

解决方案

EDIT: Since the suggestions below didn't solve the problem, and since there doesn't appear to be anything else wrong with the code you posted, I would next check to make sure the version of fitdata given above is the only function of that name on the MATLAB path. You may have inadvertently created another function or script and saved it as fitdata.m, and this may be getting called instead of the version you created above.

Previous answer:

I think you mean to use the IMPORTDATA function instead of IMPORT, which is the likely source of the error you are getting.

One additional piece of advice: it's best not to name one of your variables path, since there is already a function PATH. The variable will end up being used instead of the function (based on the MATLAB precedence rules), which will still be what you want to happen in this specific case but is a source of confusion and error in other cases.

最后

以上就是花痴飞鸟为你收集整理的c# 调matlab传字符串,我如何传递一个字符串作为一个MATLAB函数参数?的全部内容,希望文章能够帮你解决c# 调matlab传字符串,我如何传递一个字符串作为一个MATLAB函数参数?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(71)

评论列表共有 0 条评论

立即
投稿
返回
顶部