How to download a .mat file from MATLAB Onramp

조회 수: 27 (최근 30일)
Giovanni Sartori
Giovanni Sartori 2020년 8월 25일
편집: Ciro Bermudez 2021년 12월 7일
I'm doing the MATLAB Onramp as a refresher, and I have found a very interesting exercise on music chords, frequencies and Fourier Transform (10.2 Project). I would like to experiment on this using my desktop installation of MATLAB, but I need the "Cchord.mat" file. Is it available for download and personal use?
Thank you in advance.
GS
  댓글 수: 2
Kyle Sieracki
Kyle Sieracki 2020년 11월 19일
Can you post the a link/download of the data for Cchord.mat. I'm trying to do what you did and I can't figure it out
Giovanni Sartori
Giovanni Sartori 2020년 11월 19일
There is no link or direct way to download the data. In fact, the accepted answer is misleading: there is no way you can create a new .MAT file on your PC.
You have to load the Cchord.mat file (it can be done as early as Task 1) in Onramp. Then you bring up the Command Window (at the bottom of the screen; drag it upwards as to enlarge it), and simply type "y". This way, you are "printing" in the Command Window all of the values contained in the variabile "y". Then you can CTRL+A to select everything, and paste it wherever you like.
Beware: you will have to do a lot of tidying up before you can use the data.

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

채택된 답변

Shiva Katukam
Shiva Katukam 2020년 8월 27일
Direct download or saving the mat file is not supported. But you can still create a new mat file and copy the variables from the mat file you wish to download.
  댓글 수: 2
Giovanni Sartori
Giovanni Sartori 2020년 8월 27일
편집: Giovanni Sartori 2020년 11월 19일
I manually copied and pasted the content of the array (from the Onramp) into an .xlsx file on my PC, used some Excel functions to sort and clean up the data, and then imported that .xslx file into Matlab as a rectangular matrix. With a bit of matrix manipulation in Matlab, I managed to turn the matrix into a vector, and now it works perfectly.
Kyle Sieracki
Kyle Sieracki 2020년 11월 19일
Can you post the a link/download of the data for Cchord.mat. I'm trying to do what you did and I can't figure it out

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

추가 답변 (1개)

Ciro Bermudez
Ciro Bermudez 2021년 11월 19일
편집: Ciro Bermudez 2021년 12월 7일
I extracted the "Cchord.mat" using the following code:
clear; clc;
load Cchord.mat
for i = 1:3072
fprintf("%1.32f\n",y(i));
end
% 1 3072
% 3073 6144
% 6145 9216
% 9217 12288
you need to change the limits of the for cycle four times, copy and paste the result in notepad++ or sublime text, then save the file as "data.csv".
Note: to easily copy the result just select the first line, then press and hold the shift key, with the mouse move to the end and click at the end of the last line.
Finally use the following code in your desktop matlab to save a ".mat" file
clear; clc;
format long;
y = load('data.csv');
fs = 8192;
save Cchord.mat;
Remember thar the ".csv" should be in the same directory you are working on, hope it helps.
  댓글 수: 1
Giovanni Sartori
Giovanni Sartori 2021년 11월 20일
Thank you for your answer. I already managed to extract the values I needed, but I hope that your solution will help other people.

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

카테고리

Help CenterFile Exchange에서 Downloads에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by