Command line input Guide to create a blank GUI project
Arrange the controls and modify the tag name and font
Realize the linkage between the slider and the display box. The display box will show the number when the slider is dragged. The value of the function can also be changed by entering a number in the display box (the slider has a range of Min to Max, and the value entered in the display box must be within this range)
% Paste the code under the slider callback function
function fre_sliser_Callback(hObject)
v1 = get(handles.fre_slider,'Value');
s1 = sprintf('%f',v1);
set(handles.fre,'String',s1)
% Paste the code under the callback function of the display box corresponding to the slider
function fre_Callback(hObject)
s1 = get(handles.fre,'String');
v1 = str2double(s1);
set(handles.fre_slider,'Value',v1)
Paste the following code under the callback function of the signal button. In order to make the code concise, use global variables.
global Type;
Type = 1;
my_callback_fcn(handles);
my_callback_fcn is a custom function used to generate signals
function my_callback_fcn(handles)
global Type;
global fs;
global N;
global x;
fs = 44100;
dt = 1.0/fs;
T = 2;
N = T/dt;
t = linspace(0,T,N);
s1 = get(handles.fre,'String');
F = str2double(s1);
s1 = get(handles.amp,'String');
A = str2double(s1);
if Type == 1
x = 0.5*A*randn(1,N);
end
if Type == 2
x = A*sin(2*pi*F*t);
end
if Type == 3
x = A*square(2*pi*F*t);
end
if Type == 4
x = A*sawtooth(2*pi*F*t,0.5);
end
plot(handles.axes1,t,x,'b','LineWidth',5);
axis(handles.axes1,[0,0.01,-2500,2500]);
grid(handles.axes1);
Paste the code under the callback function corresponding to the play button
function Play_Callback(hObject)
global fs;
global x;
y = x*0.0003;% decay
sound(y,fs);
Advanced content, play and pause the signal, set the timer
global mytimer
mytimer = timer('StartDelay',1,'Period',1,'TasksToExecute',150,'ExecutionMode','fixedRate');
mytimer.TimerFcn = {@my_callback_fcn};
% Run the code under the play button callback function
global mytimer;
start(mytimer);
% Code under the Stop pause button callback function
global mytimer;
stop(mytimer);
To generate figure1_CreateFcn in the entire graphical interface, right-click CreateFcn
Final Result
The code comes from "Theory and Practice of Digital Signal Analysis" of Huazhong University of Science and Technology, only for learning summary
Previous article:Function signal generator based on Multisim - square wave, triangle wave, sine wave
Next article:Sine Signal Generator Design——VHDL
Recommended ReadingLatest update time:2024-11-22 13:41
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- Modern manufacturing strategies drive continuous improvement in ICT online testing
- Methods for Correlation of Contact and Non-Contact Measurements
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- RAQ #223: How to measure and determine soft-start timing without a soft-start equation?
- RAQ #223: How to measure and determine soft-start timing without a soft-start equation?
- GigaDevice's full range of automotive-grade SPI NOR Flash GD25/55 wins ISO 26262 ASIL D functional safety certification
- GigaDevice's full range of automotive-grade SPI NOR Flash GD25/55 wins ISO 26262 ASIL D functional safety certification
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- Infineon Technologies Launches ModusToolbox™ Motor Kit to Simplify Motor Control Development
- Infineon Technologies Launches ModusToolbox™ Motor Kit to Simplify Motor Control Development
- STMicroelectronics IO-Link Actuator Board Brings Turnkey Reference Design to Industrial Monitoring and Equipment Manufacturers
- Melexis uses coreless technology to reduce the size of current sensing devices
- Research on the mechanical device of automobile fuel gauge and sensor test and detection system
- 【XMC4800 Relax EtherCAT Kit Review】+ FreeRTOS real-time system usage
- 【Silicon Labs BG22-EK4108A Bluetooth Development Evaluation】+ Development Environment Construction
- Infineon Tmall flagship store offers huge discounts Part 1 - Limited cashback on a first-come, first-served basis, Double 11 special promotion!
- Power management takes the lead in industry recovery
- Cadence collaborates with industry leaders to address low-power technology barriers in the electronics industry
- Good evening, experts.
- The startup method of high performance DSP in large capacity wireless transmission technology
- You may need oscilloscope information urgently, especially analog ones. You can get the information here.
- Share: Qinheng CH32V103 built-in Flash to extend the use time and balance wear and write