Using variable set in app designer callback for SCPI command in MATLAB function

11 ビュー (過去 30 日間)
Alice de Whalley
Alice de Whalley 2020 年 9 月 10 日
Using app designer to run a function which includes a SCPI command:
function [measuredGain, measuredPhase] = VNA_ReadData(visaObj)
%
% Inputs: visaObj - Object handler for VNA. Set using another function.
% Outputs: measuredGain - gain measured from VNA in dB
% measuredPhase - phase measured from VNA in degrees
% Retrieve Marker data for R&S VNA ZNB20
M1 = query(visaObj, 'CALCulate1:MARKer1:Y?'); %ChannelNo=1, MarkerNo=1
% % Split gain and phase values into two value array
M1_new = split(M1,",");
% % Convert strings into number and assign to output variable
measuredGain = str2double(M1_new(1));
measuredPhase = str2double(M1_new(2));
end
When run in the command window,
[measuredGain, measuredPhase] = VNA_ReadData(visaObj)
successfully outputs measuredGain and measuredPhase.
However, when run in a callback in app designer,
[measuredGain, measuredPhase] = VNA_ReadData(app.visaObj)
where visaObj is a property, returns the error:
Undefined function 'query' for input arguments of type 'double'.
M1 = query(visaObj, 'CALCulate1:MARKer1:Y?'); %ChannelNo=1, MarkerNo=1
This appears to be due to a difference in visaObj in matlab and app.visaObj in app designer: The same 1x1 Visa, called visaObj, has different "ValuesSent" and "ValuesReceived" depending on whether it is called in MATLAB or App Designer.
VISA-TCPIP Object Using RS Adaptor : VISA-TCPIP-0-169.254.168.142-inst0 %Visa Address of Network Analyzer in use.
Communication Address
RemoteHost: 169.254.168.142 %IP Address - Network Analyzer is connected by Ethernet
Communication State
Status: open
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 10 % Discrepency in this value between app designer and MATLAB
ValuesSent: 305 % Discrepency in this value between app designer and MATLAB
but the visaObj is set to base workspace in app designer using
assignin('base','visaObj',app.visaObj)
so they should be identical. Any suggestions as to why this is happening would be much appreciated.
Could it be the way I am sharing variables between app designer and a matlab function/script? I've also tried save/load but get the same error.

回答 (0 件)

カテゴリ

Help Center および File ExchangeInstrument Control Toolbox についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by