フィルターのクリア

How can data gradually be exported to an Excel file?

1 回表示 (過去 30 日間)
Erik Näslund
Erik Näslund 2019 年 7 月 14 日
コメント済み: Erik Näslund 2019 年 7 月 14 日
I am having/creating several workspaces of different recorded data, representing a function (called RS). At four different occasions data/blood samplings were done at different times (”a”, ”b”, ”c” and ”d” respectively). Via a ”input”-function I can assign the current times to respective data sampel. After that, I create a +/- 15 s interval of each data sampel and calculate the mean.
a = input('seconds:');
b = input('seconds:');
c = input('seconds:');
d = input('seconds:');
% Determine the different intervals and mean-values:
ai = (a-15:a+15)
bi = (b-15:b+15)
ci = (c-15:c+15)
di = (d-15:d+15)
mai = mean(RS(ai))
mbi = mean(RS(bi))
mci = mean(RS(ci))
mdi = mean(RS(di))
Is there a way, to export the data to an Excel spreadsheet, with the name of the different workspaces in column 1 and the different mean-values in columns 2 to 4, and every time the code is run a new row is added with the current values?
I hope someone can help me! Thank you

採用された回答

Image Analyst
Image Analyst 2019 年 7 月 14 日
編集済み: Image Analyst 2019 年 7 月 14 日
You could just read in the existing worksheet and find out the last row:
if isfile(filename)
% Read in existing file to get its last row.
[numbers, strings, raw] = xlsread(filename);
[rows, columns] = size(raw);
else
% File doesn't exist yet.
rows = 0;
columns = 0;
end
then when you make up a cell reference, start writing at the next row
nextRow = rows + 1; % Or wherever you want.
cellRef = sprintf('A%d', nextRow);
xlswrite(filename, data, worksheetName, cellRef);
  1 件のコメント
Erik Näslund
Erik Näslund 2019 年 7 月 14 日
Thank you for your help! But, unfortunately I must be missing something and can’t get the code to work. Since I’m fairly unexperienced using Matlab I am wondering if you could provide me with a concrete example using the following conditions?
Filename = testdata
Matlab workspace savename = GX_RY (unique name for all the different recordings)
Organisation/headers of the Excel file: ‘Workspace name’, ‘mai’, ‘mbi’, ‘mci’, ‘mdi’
Worksheet name – it doesn’t matter…
I very much appreciate your help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by