Store .csv data and calculate average value

6 次查看(过去 30 天)
Goodmorning to everybody.
Can someone help me to understand how I can save in matlab 10 .csv files, select only the columns in which I am interested and get as output a final plot in which I have the average value of the y coloumns and standard deviation of y axes? I am not so good in matlab and so I kindly ask if someone to help me to solve this question.
Thanks in advance.

采纳的回答

Walter Roberson
Walter Roberson 2015-9-12
Roughly,
which_column = 7; %for example
for K = 1 : 10
filedata = csvread(FileNames{K})
columndata(:,K) = filedata(:,which_column);
end
columnavg = mean(columndata,2);
columnstd = std(columndata,2);
xvals = 1 : size(columnavg,1);
plot(xvals, columnavg, 'b-', xvals, columnavg-columnstd, 'r--', xvals, columnavg+columstd, 'r--');
This would plot the average and would also plot the positions that are 1 standard deviation above and below the average.
  11 个评论
Walter Roberson
Walter Roberson 2015-9-14
K is not intended to be a matrix. K is a loop counter. You are having problems on the first file. Show us
dirstats(K).name
dirstats(K).bytes
size(num)
size(txt)
size(raw)
Snapshot83
Snapshot83 2015-9-14
编辑:Snapshot83 2015-9-14
Now it works, thanks. My basic error was that I didn't delete an old file inside the folder so I didn't process properly my data.
I have a second problem. How I can copy this data in an excel file properly? I used the function xlswrite but maybe something is wrong. If I write
xlswrite('file1.xlsx', m),
for exemple, I am not able to see the file created inside the folder.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by