error while using subplot
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Rohit singla
il 7 Ott 2017
Commentato: Brion Root
il 9 Apr 2020
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 Commenti
Risposta accettata
Walter Roberson
il 7 Ott 2017
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Subplots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!