error while using subplot
3 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!