An easy way to input song chords into a structure of MATLAB
이전 댓글 표시
Hello. I'd like to know the way to enter the name of the song chords into the structure of MATLAB easily.
I do research about the related between chords and a piece of music, and I analyze the chords progression in MATLAB. Howerver, it takes too many time to enter the name of chords by hands like this;
chords = struct( ...
'name', {}, ... % name of chords(ex: 'Cmaj7')
'start_sec', {}, ... % start time[s]
'end_sec', {} ... % end time[s]
);
N=input('the number of chords: ');
BPM=input('BPM: ');
chords(1).start_sec=0;
for i=1:N
fprintf('\n===== Chord %d =====\n', i);
chords(i).name=input('Name: '); %''
Start=input('Start beat: ');
chords(i).start_sec=(60/BPM)*4*(Start-1);
if i >= 2
chords(i-1).end_sec=(60/BPM)*4*(Start-1);
end
end
ends=input('End beat: ');
chords(N).end_sec=(60/BPM)*4*ends;
save("chords_yoruni.mat","chords");
I am a beginner when it comes to programming, so I don't have any idea. I would like you to tell me even small things.
Thank you for your help
댓글 수: 2
INPUT() is a rather tedious and unreliable way to enter data. A much better approach is to import the data from a file, webpage, or something like that. Do you have a well-formatted source for these data?
Chino
2026년 1월 14일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Direction of Arrival Estimation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!