How to save normalized data set in file for using it again?

I have dataset in csv file. I have normalized it using
Data = rand(10, 20); % Test data, use your data instead
minData = min(Data(:));
maxData = max(Data(:));
scaled = (Data - minData) / (maxData - minData); % Scaled to [0, 1]
scaled = scaled * 2 - 1; % Scaled to [-1, 1]
now the data is normalized, i want to save the normalized data in file again like csv, txt etc.

1 件のコメント

Jan
Jan 2017 年 4 月 28 日
Do you see that the shown code is not relevant for your question? A scaled = rand(2,5) would be sufficient also.

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

 採用された回答

Walter Roberson
Walter Roberson 2017 年 4 月 27 日

0 投票

You could use save() or csvwrite() or dlmwrite() or xlswrite()
I would suggest saving as a binary .mat file unless you need it as text for another program.

6 件のコメント

tejasvee
tejasvee 2017 年 4 月 28 日
It gives error while using any of above. Error using save Unable to write file matlab.mat: permission denied. I want to use the normalized data for my another program.I want to use it to train my machine and it require normalized data.
tejasvee
tejasvee 2017 年 4 月 28 日
編集済み: Walter Roberson 2017 年 4 月 28 日
Data= csvread('dataset.csv');
Data = rand(10, 20); % Test data, use your data instead
minData = min(Data(:));
maxData = max(Data(:));
scaled = (Data - minData) / (maxData - minData); % Scaled to [0, 1]
scaled = scaled * 2 - 1; % Scaled to [-1, 1]
save('dataset.csv')
Jan
Jan 2017 年 4 月 28 日
The error message means, that you do not have write permissions in the current folder or that you try to write to a protected file. Again: the code to create the data is not relevant for the question. Concentrate on the details.
tejasvee
tejasvee 2017 年 4 月 28 日
It means i can't use normalized data set in matlab which is again saved to file to train my machine.
Walter Roberson
Walter Roberson 2017 年 4 月 28 日
save() does not save in csv form.
save dataset.txt scaled -ascii -double %text format but not commas
or
csvwrite('dataset.csv', scaled)
tejasvee
tejasvee 2017 年 4 月 29 日
Thanks it was helpful and it worked.

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

その他の回答 (0 件)

質問済み:

2017 年 4 月 27 日

コメント済み:

2017 年 4 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by