【问题标题】:Matlab codes for making scalesMatlab制作刻度的代码
【发布时间】:2017-11-23 00:31:59
【问题描述】:

我从 Excel 文件中提取了某些数据。 它涉及两列:一列用于特定时期,另一列用于相应时间。 每日价格。以下是我的代码。(t1 和 t2 是用户输入。)

row_1 = find(period==t1)
row_2 = find(period==t2)
f_0 = period(row_1:row_2, 1)
f_1 = price(row_1:row_2 , 1) 
y_1 = plot(handles.axes2, f_0, f_1)

f_0:周期(x 轴),f_1:价格(y 轴)

我的目标是通过声音来表达价格波动的趋势。 所以我想出的方法如下。 Step1:求给定期间对应的价格的最大值和最小值。 Step2:将这两点之间的距离分成八段。 Step3:为每个音阶分配八个音阶(C D E F G A B C) 八个部分并播放它。

在我的水平上,我找到了给定时间段的最小值/最大值。 但从下一阶段开始,我想不出任何想法。 请给我任何建议。

【问题讨论】:

    标签: matlab


    【解决方案1】:

    如果我理解正确,您想将八个音阶分配给划分的时期,这样的代码可能会有所帮助。

    %% let's play some music~
    clc; clear;
    
    %% Set the Sampling frequency & time period
    fs=44100;
    t=0:1/fs:0.5;
    
    %% eight musical scales
    Cscale{1}=sin(2*pi*262*t); %c-do
    Cscale{2}=sin(2*pi*294*t); %c-re
    Cscale{3}=sin(2*pi*330*t); %c-mi
    Cscale{4}=sin(2*pi*349*t); %c-fa
    Cscale{5}=sin(2*pi*392*t); %c-so
    Cscale{6}=sin(2*pi*440*t); %c-la
    Cscale{7}=sin(2*pi*494*t); %c-ti
    Cscale{8}=sin(2*pi*523*t); %c-do-high
    %you could call "sound(Cscale{i},fs)" to paly each scales
    
    
    %% Divide the distances between these two points
    % the highest point must be special treated
    Min_p=0;
    Max_p=8;
    Sample_p=[0 1 2 3 4 5 6 7 8];
    for i=1:length(Sample_p)
      S_p=Sample_p(i);
      if (S_p == Max_p)
        sound(Cscale{end},fs);
      else
          %Find the correct music scale and play it
          sound(Cscale{1+floor(8*(Sample_p(i)-Min_p)/(Max_p-Min_p))},fs);
      end
      pause(0.5)
    end
    

    这是我看的(你可能需要谷歌翻译,因为它是用中文写的)

    http://blog.csdn.net/weaponsun/article/details/46695255

    【讨论】:

      猜你喜欢
      • 2021-04-11
      • 1970-01-01
      • 1970-01-01
      • 2015-07-29
      • 1970-01-01
      • 1970-01-01
      • 2012-03-04
      • 2014-12-02
      • 1970-01-01
      相关资源
      最近更新 更多