error while using subplot

3 ビュー (過去 30 日間)
Rohit singla
Rohit singla 2017 年 10 月 7 日
コメント済み: Brion Root 2020 年 4 月 9 日
code:
t=0:0.001:1;
set(0,'defaultlinelinewidth',2);
A=5;%Amplitude of signal
fm=input('Message frequency=');%Accepting input value
fc=input('Carrier frequency=');%Accepting input value (f2>f1)
mi=input('Modulation Index=');%Modulation Index
Sm=A*sin(2*pi*fm*t);%Message Signal
subplot(3,1,1); %Plotting frame divided in to 3 rows and this fig appear at 1st
plot(t,Sm);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;
Sc=A*cos(2*pi*fc*t);%Carrier Signal
subplot(3,1,2);
plot(t,Sc);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
grid on;
Sfm=(A+mi*Sm).*sin(2*pi*fc*t);%AM Signal, Amplitude of Carrier changes to (A+Message)
subplot(3,1,3);
plot(t,Sfm);
xlabel('Time');
ylabel('Amplitude');
title('AM Signal');
grid on;
but when i run the program,show this type of error given below:
Attempt to execute SCRIPT subplot as a function:
C:\Users\Rohit\Documents\MATLAB\subplot.m
Error in subplot (line 8)
subplot(3,1,1); %Plotting frame divided in to 3 rows and this fig appear at 1st.

採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 7 日
You created a .m file named C:\Users\Rohit\Documents\MATLAB\subplot.m which is interfering with using the MATLAB subplot() function. You must either rename C:\Users\Rohit\Documents\MATLAB\subplot.m to something else, or else make sure that it later on your MATLAB path than toolbox/matlab/graph2d/subplot.p is.
I would advise you that as long as you have your own subplot.m that you are going to run into this problem over and over again. Creating your own .m named the same thing as one of the common MATLAB functions is "asking for trouble".
  2 件のコメント
Rohit singla
Rohit singla 2017 年 10 月 7 日
Thanks a lot Now its working
Brion Root
Brion Root 2020 年 4 月 9 日
Yea wow this helped me too, even my teacher didn't know why.
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by