Send command on serial port : "Invalid argument at position 1. Value must be a scalar." why ?
23 ビュー (過去 30 日間)
古いコメントを表示
foundVISA = visadevlist;
resourceCOM = foundVISA(foundVISA.Model == "9214",:).ResourceName; % 9214 Model pulse generator from QC
resourceCOM = resourceCOM(contains(resourceCOM,"9214")); % Extract resourceCOM which contains "9214"
pulseGenerator = visadev(resourceCOM);
% writeline(pulseGenerator,"*RST"); % send RESET to pulse generator for resets parameters to default
instrumentInfo = writeread(pulseGenerator,"*IDN?");
fprintf("Instrument identification information: %s",instrumentInfo);
"Invalid argument at position 1. Value must be a scalar."
what i do wrong ? Thanks for your help.
0 件のコメント
採用された回答
Deep
2023 年 7 月 10 日
In your code,
resourceCOM = foundVISA(foundVISA.Model == "9214",:).ResourceName; % 9214 Model pulse generator from QC
resourceCOM = resourceCOM(contains(resourceCOM,"9214")); % Extract resourceCOM which contains "9214"
pulseGenerator = visadev(resourceCOM);
In the first line, you're trying to filter the foundVISA table based on the Model and get the ResourceName.
In the second line, you're filtering the resulting resourceCOM to only get entries which contain "9214".
If your filtering operations result in multiple entries (more than one "ResourceName" containing "9214"), then resourceCOM isn't a scalar, it's a vector or an array of strings. When you then try to create a pulseGenerator object using the visadev function, it expects a scalar string argument, but you're providing a non-scalar resourceCOM, hence the error.
You should choose which resource you want to pass based on some criteria. For example, simply use the first resource returned.
if ~isempty(resourceCOM)
resourceCOM = resourceCOM(1);
end
pulseGenerator = visadev(resourceCOM);
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!