Turn code into function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
FP= {'Please enter three frequencies [f1 f2 f3]:'};
prompt_title = 'Frequency Data?';
dims = [1 1000];
default = {'1 1 1'};
FP_index = inputdlg(FP, prompt_title, dims, default);
FP_MATRIX = cell2mat(FP_index)
AMP= {'Please enter three amplitudes [a1 a2 a3]:'};
prompt_title1 = 'Amplitude Data?';
dims = [1 1000];
default = {'1 1 1'};
AMP_index = inputdlg(AMP, prompt_title1, dims, default);
AMP_MATRIX = cell2mat(AMP_index)
T= linspace(1,3,1000)
Sin1= AMP_MATRIX(1)*sin(2*pi*FP_MATRIX(1)*T)
Sin2= AMP_MATRIX(2)*sin(2*pi*FP_MATRIX(2)*T)
Sin3 = AMP_MATRIX(3)*sin(2*pi*FP_MATRIX(3)*T)
plot(T,Sin1,'-g',T,Sin2,'-b',T,Sin3,'-k')
hold on;
Sin= Sin1 + Sin2 +Sin3
plot(T,Sin,'-r','LineWidth',2);
xlabel('Time');
ylabel('Signals')
legend('S_1','S_2','S_3','Output signal');
title('Plots of three signals and sum')
hold off
My code is above I am trying to turn this whole thing into a function using one line of code.
0 commentaires
Voir également
Catégories
En savoir plus sur Waveform Generation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!