Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
制作电子秤的Matlab代码_Matlab - Fatal编程技术网

制作电子秤的Matlab代码

制作电子秤的Matlab代码,matlab,Matlab,我从Excel文件中提取了某些数据。 它包括两列:一列用于特定时期,另一列用于对应时期 每日价格。以下是我的代码。(t1和t2是用户输入。) f_0:周期(x轴),f_1:价格(y轴) 我的目标是用声音来表达价格波动的趋势。 我得出的结论如下。 步骤1:找到给定期间对应的价格的最大值和最小值。步骤2:将这两点之间的距离划分为八个部分。第三步:给每个人分配八个音阶(C D E F G A B C) 八节并播放它 在我的水平上,我找到了给定周期的最小/最大值。 但从下一阶段开始,我想不出任何想法。

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

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

我的目标是用声音来表达价格波动的趋势。 我得出的结论如下。 步骤1:找到给定期间对应的价格的最大值和最小值。步骤2:将这两点之间的距离划分为八个部分。第三步:给每个人分配八个音阶(C D E F G A B C) 八节并播放它

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

如果我没听错的话,你想把八个音阶分配给分频周期,这样的代码可能会有帮助

%% 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
这是我看到的(你可能需要谷歌翻译,因为它是用中文写的)

%% 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