I'm trying to run an instrument (that understands scpi commmands) four times. It stores its data in different rows and columns within the same array. As there are four variables, running four times, there are sixteen columns. There are also twenty-one data points, so there are twenty-one data rows. I'm trying to append the array, and it's not working for some reason. All the code within the "for" function works like a charm, except for the last four lines. Is there a bug that I'm not seeing? Thank you.
global analyzerData;
analyzerData = zeros(21,16);
global i
for i = 1:4
disp(i)
strcat('PAGE:CHAN:SMU', int2str(mod(i,4)), ':MODE COMM'); % Set the first SMU to COMM
strcat('PAGE:CHAN:SMU', int2str(mod(i,4)), ":INAME 'IS'"); % Set current name
strcat('PAGE:CHAN:SMU', int2str(mod(i,4)), ":VNAME 'VS'"); % Set voltage name
strcat('PAGE:CHAN:SMU', int2str(mod(i+1,4)), ':MODE V'); % Set the next SMU to current mode
strcat('PAGE:CHAN:SMU', int2str(mod(i+1,4)), ':FUNC VAR1'); % see if VAR1 works. If not, then change to different variables
strcat('PAGE:CHAN:SMU', int2str(mod(i+1,4)), ":INAME 'ID'"); % Set current name
strcat('PAGE:CHAN:SMU', int2str(mod(i+1,4)), ":VNAME 'VD'"); % Set voltage name
strcat('PAGE:CHAN:SMU', int2str(mod(i+2,4)), ':DIS'); % Disable third SMU
strcat('PAGE:CHAN:SMU', int2str(mod(i+3,4)), ':DIS'); % Disable fourth SMU
fprintf(analyzer, 'PAGE:MEAS:VAR1:MODE SING'); % Do execution only once
fprintf(analyzer, 'PAGE:MEAS:VAR1:START 0'); % Start
fprintf(analyzer, 'PAGE:MEAS:VAR1:STEP 0.05'); % Steps
fprintf(analyzer, 'PAGE:MEAS:VAR1:STOP 1.0'); % Stop
fprintf(analyzer, 'PAGE:MEAS:VAR1:COMP 0.1'); % Compliance
fprintf(analyzer, 'PAGE:MEAS:DEL 0.01'); % Timing. Also experiment with this value for speed and accuracy
fprintf(analyzer, 'PAGE:SCON:SING'); % Single execution
fprintf(analyzer, '*WAI'); % Wait until the command is done
analyzerData(:,((i-1)*4)+0) = transpose(str2num(query(analyzer, "DATA? 'VS'")));
analyzerData(:,((i-1)*4)+1) = transpose(str2num(query(analyzer, "DATA? 'IS'")));
analyzerData(:,((i-1)*4)+2) = transpose(str2num(query(analyzer, "DATA? 'VD'")));
analyzerData(:,((i-1)*4)+3) = transpose(str2num(query(analyzer, "DATA? 'ID'")));
end

 採用された回答

dpb
dpb 2018 年 7 月 17 日

1 投票

analyzerData(:,((i-1)*4)+4) = transpose(str2num(query(analyzer, "DATA? 'VS'")));
analyzerData(:,((i-1)*4)+4) = transpose(str2num(query(analyzer, "DATA? 'IS'")));
analyzerData(:,((i-1)*4)+4) = transpose(str2num(query(analyzer, "DATA? 'VD'")));
analyzerData(:,((i-1)*4)+4) = transpose(str2num(query(analyzer, "DATA? 'ID'")));
Each of the four is writing to the same column instead of sequential
analyzerData(:,((i-1)*4)+4+0) = transpose(str2num(query(analyzer, "DATA? 'VS'")));
analyzerData(:,((i-1)*4)+4+1) = transpose(str2num(query(analyzer, "DATA? 'IS'")));
analyzerData(:,((i-1)*4)+4+2) = transpose(str2num(query(analyzer, "DATA? 'VD'")));
analyzerData(:,((i-1)*4)+4+3) = transpose(str2num(query(analyzer, "DATA? 'ID'")));
to make it explicitly clear; I'd probably recast to compute the indices only once thru the loop, but the overhead isn't enough to matter significantly.

1 件のコメント

Marek Hempel
Marek Hempel 2018 年 7 月 17 日
編集済み: Marek Hempel 2018 年 7 月 17 日
Thank you. The issue is resolved.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMultidimensional Arrays についてさらに検索

製品

リリース

R2018a

質問済み:

2018 年 7 月 17 日

編集済み:

2018 年 7 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by