how to create a function for loading data

조회 수: 2 (최근 30일)
abuzer
abuzer 2014년 4월 1일
댓글: Azzi Abdelmalek 2014년 4월 1일
Dear all,
I have question about how to create a function for loading data from file.
for example: I have a code, but I import datas from 2 different txt file. now I want to create a function for choosing these files and code will automatically work. how can we solve this problem??
thanks

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 1일
You, already have a function that loads your data
file='file1.txt'
data=dlmread(file)
  댓글 수: 2
abuzer
abuzer 2014년 4월 1일
thank you for your answer.
Yes I know many functions importing datas but my question is that just crate function like this
function target= calculate(data1.txt, data2.txt) than when I write this function will run my codes on command windows. I have tried but failed. because function inputs have to be a value? or sth like this..??
Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 1일
files={'data1.txt','data2.txt'},
out=cellfun(@(x) dlmread(x),files,'un',0)
celldisp(out)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by