Check for incorrect argument data type or missing argument in call to function 'sin'.

I'm simulating modulation of my audio signal into a carrier wave.
clc
clear all;
close all;
%Audio
ADS = audioDatastore("AUDIO.wav");
info = audioinfo('AUDIO.wav');
[y,Fs] = audioread('AUDIO.wav');
sound(y,Fs)
t = 0:seconds(1/Fs):seconds(info.Duration);
t = t(1:end-1);
%Carrier Wave
Fc = 400000;
Ca = 100;
Cs = Ca*sin(2*pi*Fc*t);
%Amplitude Modulation
x = modulate(y,Cs,Fs);
%Plot
subplot(3,1,1);
plot(t,y)
xlabel('Time')
ylabel('Audio Signal')
subplot(3,1,2);
plot([y,Fs]);
title('Carrier');
ylabel('Amplitude');
subplot(3,1,3);
plot(x);
title('Modulated Amplitude');
ylabel('Amplitude');

9 个评论

After the line
t = t(1:end-1);
include the lines
size(t)
class(t)
What information does MATLAB print ?
The class of t is "duration". This is not accepted by the sin-function.
Use
t = 0:seconds(1/Fs):seconds(info.Duration);
t = t(1:end-1);
t = seconds(t);
instead of
t = 0:seconds(1/Fs):seconds(info.Duration);
t = t(1:end-1);
I still get the same message " Check for incorrect argument data type or missing argument in call to function 'sin'. "
clc
clear all;
close all;
%Audio
ADS = audioDatastore("AUDIO.wav");
info = audioinfo('AUDIO.wav');
[y,Fs] = audioread('AUDIO.wav');
sound(y,Fs)
t = 0:seconds(1/Fs):seconds(info.Duration);
t = t(1:end-1);
size(t)
class(t)
%Carrier Wave
Fc = 400000;
Ca = 100;
Cs = Ca*sin(2*pi*Fc*t);
%Amplitude Modulation
x = modulate(y,Cs,Fs);
%Plot
subplot(3,1,1);
plot(t,y)
xlabel('Time')
ylabel('Audio Signal')
subplot(3,1,2);
plot([y,Fs]);
title('Carrier');
ylabel('Amplitude');
subplot(3,1,3);
plot(x);
title('Modulated Amplitude');
ylabel('Amplitude');
The result
clc;
clear all;
close all;
%Audio
ADS = audioDatastore("AUDIO.wav");
info = audioinfo('AUDIO.wav');
[y,Fs] = audioread('AUDIO.wav');
sound(y,Fs);
t = 0:seconds(1/Fs):seconds(info.Duration);
t = t(1:end-1);
t = seconds(t);
size(t)
class(t)
%Carrier Wave
Fc = 400000;
Ca = 100;
Cs = Ca*sin(2*pi*Fc*t);
%Amplitude Modulation
x = modulate(y,Cs,Fs);
%Plot
subplot(3,1,1);
plot(t,y);
xlabel('Time')
ylabel('Audio Signal')
subplot(3,1,2);
plot([y,Fs]);
title('Carrier')
ylabel('Amplitude')
subplot(3,1,3);
plot(x);
title('Modulated Amplitude')
ylabel('Amplitude')
The command
plot([y,Fs])
does not make sense.
Read again what the outputs from "audioread" mean.
y is a vector, Fs is a scalar value.
Code Check:
clc;
clear all;
close all;
%Audio
ADS = audioDatastore("AUDIO.wav");
info = audioinfo('AUDIO.wav');
[y,Fs] = audioread('AUDIO.wav');
sound(y,Fs);
t = 0:seconds(1/Fs):seconds(info.Duration);
t = t(1:end-1);
t = seconds(t);
size(t)
class(t)
%Carrier Wave
Fc = 22000;
Ca = 100;
Cs = Ca*sin(2*pi*Fc*t);
%Amplitude Modulation
x = modulate(y,Cs,Fs);
%Plot
subplot(3,1,1);
plot(t,y);
xlabel('Time')
ylabel('Audio Signal')
subplot(3,1,2);
plot(y,Fs);
title('Signal')
ylabel('Amplitude')
subplot(3,1,3);
plot(x);
title('Modulated Amplitude')
ylabel('Amplitude')
Is there a problem with the signal plotting or it's just it?
Fs is your sampling frequency for the audio. It does not change over time. And you are using your -1 to +1 audio signal as your independent variable for the plot.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Measurements and Feature Extraction 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by