Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Knowledge Base Home
  • Contact Us
  • Home
  • Software integrations
  • MATLAB examples

MATLAB: Spectrum Analyzer (plotting)

Written by Paul Cracknell

Updated at December 22nd, 2020

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Moku:Lab Instruments
    Arbitrary Waveform Generator Data Logger Digital Filter Box FIR Filter Builder Frequency Response Analyzer Laser Lock Box Lock-in Amplifier Oscilloscope Phasemeter PID Controller Spectrum Analyzer Waveform Generator
  • Moku:Lab general
    Getting Started with Moku:Lab Using Moku:Lab Hardware
  • iPad app
  • Windows
  • Software integrations
    Python Python examples MATLAB MATLAB examples LabVIEW
+ More

Example MATLAB script to implement the Spectrum Analyzer (plotting)

%% Plotting Spectrum Analyzer Example
% 
% This example demonstrates how you can configure the Spectrum Analyzer 
% instrument and plot its spectrum data in real-time. It also shows how
% you can use its embedded signal generator to generate a sweep and single
% frequency waveform on the output channels.
% 
% (c) 2017 Liquid Instruments Pty. Ltd.
% 
%% Connect to your Moku
ip = input('Please enter your Moku:Lab IP address: ', 's');

% Connect to your Moku and deploy the desired instrument
m = MokuSpectrumAnalyzer(ip);

%% Configure the instrument
% Set amplitude scale to dBm
m.set_dbmscale('dbm','true');

% Set DC - 70MHz span
m.set_span(10e6,70e6);

% Auto mode
m.set_rbw();

% Generate swept 1.0Vpp Sinewave on Channel 1
m.gen_sinewave(1,1.0,0,'sweep','true');
% Generate 0.5Vpp 20MHz Sinewave on Channel 2
m.gen_sinewave(2,0.5,20e6,'sweep','false');

% Configure the ADC inputs to be 50Ohm impedance
m.set_frontend(1,'fiftyr','true');
m.set_frontend(2,'fiftyr','true');

%% Set up plots
% Get initial data to set up plots
data = m.get_data();

% Set up the plots
figure;
lh = plot(data.frequency, data.ch1, data.frequency, data.ch2);
axis tight;
xlabel(gca,'Frequency (Hz)');
if data.dbm
 ylabel(gca,'Amplitude (dBm)');
else
 ylabel(gca,'Amplitude (V)');
end

%% Receive and plot new data frames
while 1
 data = m.get_realtime_data();
 set(lh(1),'XData',data.frequency,'YData',data.ch1);
 set(lh(2),'XData',data.frequency,'YData',data.ch2);
 pause(0.1);
end
moku:lab

Was this article helpful?

Yes
No

Related Articles

  • MATLAB datalogger and saving the logfile
  • MATLAB: PID controller
  • MATLAB: Lock-in Amplifier
  • MATLAB: Frequency Response Analyzer (plotting)

Sitemap

  • Moku:Lab
  • Instruments
  • Software
  • Company
  • Support
  • Store
  • Terms & Conditions
  • Privacy Policy

Offices

United States
+1 (619) 332-6230
740 Lomas Santa Fe Dr
Suite 102
Solana Beach, CA 92075

Australia
+61 2 6171 9730
243 Northbourne Avenue
Suite 2
Lyneham, ACT 2602

Follow us

Youtube LinkedIn

官方微信

Contact us
© 2021 Liquid Instruments. All rights reserved.

Definition by Author

0
0
Expand