Hello,
I'm trying to write a script general enough to read complex valued data from a varying number of .csv files. I've been using dir for this, but this seems to only pull in the real values from the file. Is there some way to get both the real and imaginary values with dir or should I be using a different function? Here is the code:
fnames = dir(['Received_Signals\Gain\',gain_directory,'\*.csv']);
numfids = length(fnames);
vals = cell(1,numfids);
for k = 1:numfids
vals{k} = load(fnames(k).name);
end
for ig = 1: indep_gain_ct
if ig == 1
GHP_read = vals{1};
GHT_read = vals{2};
GVP_read = vals{3};
GVT_read = vals{4};
else
GHP_read = cat(3,GHP_read,vals{1+4*(ig-1)});
GHT_read = cat(3,GHT_read,vals{2+4*(ig-1)});
GVP_read = cat(3,GVP_read,vals{3+4*(ig-1)});
GVT_read = cat(3,GVT_read,vals{4+4*(ig-1)});
end % if ig
end % for ig
Thanks.

 채택된 답변

Star Strider
Star Strider 2016년 10월 28일

0 개 추천

I doubt dir is the problem, since it’s just providing you with the file names.
We don’t have a sample file to experiment with, so it’s possible that using the load function is the problem. Experiment with csvread and xlsread to see if they work.
This is a pure guess. I’m not certain what the problem is.

댓글 수: 2

Jeff M
Jeff M 2016년 10월 28일
Your guess was completely right. All that I needed to do was replace load with csvread.
Thanks.
Star Strider
Star Strider 2016년 10월 28일
My pleasure.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

질문:

2016년 10월 28일

댓글:

2016년 10월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by