How do I write a function to load a file with the string of the filename as the input?

1 回表示 (過去 30 日間)
Matthew
Matthew 2018 年 1 月 26 日
回答済み: Matthew 2018 年 1 月 26 日
For example:
I want to be able to input mytestfunction('teststring'), then have matlab load my file and perform all the follow up calculations I already have coded. The file is a .csv file.
Sample code (what I have):
function D = mytestfunction(filename)
L = csvread(filename);
...post-processing code etc...
end
As a follow on, I will also need to remove the first row of the csv when loaded and I haven't been able to apply the dlmread command correctly. Is
X=dlmread(filename, ' ', 1, 0)
the correct syntax for this?

採用された回答

Matthew
Matthew 2018 年 1 月 26 日
There was a 'clear' I missed in one of the early lines, that cleared my function input and caused an error. Removing 'clear' fixed my issue.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by