I wish to know how to automatically draw a constant current , each time the program runs.

조회 수: 1 (최근 30일)
for example, Amp = [1,2,3,4,5]
fprintf(eLOAD_instr, 'curr %2f',Amp(0)) , I change Amp(1), Amp(2) each time program runs.
This is the #Setpoint I am giving to the instrument for me to do the calculations.
So how to make a script which automatically takes the next value from 'Amp' when I run it.

답변 (1개)

Jan
Jan 2017년 11월 29일
Define the variables:
Amp = [1,2,3,4,5]
index = 0;
Now call this code:
index = index + 1;
fprintf(eLOAD_instr, 'curr %2f', Amp(index));
If you show us the context of your code lines, it might be possible to suggest a more precise solution, perhaps a persistent variable:
function yourCode
persistent index Amp
if isempty(index)
index = 0;
Amp = [1,2,3,4,5]
end
index = index + 1;
disp(Amp(index))
end
Now you can call this function repeatedly and index is incremented automatically - until you get an out-of-range error for index=6.
  댓글 수: 2
arvind ramasamy
arvind ramasamy 2017년 11월 29일
Amp=1; while(exit) i=i+1; tic %reference = S(i);
fprintf(eLOAD_instr, 'curr %2f',Amp) % Setpoint to eLOAD
pause(0.1)
%%Get Data from ELR9000
% Setpoint, Current, Voltage, Power
Data_eLOAD_string = query(eLOAD_instr, 'curr?; measure:current?; measure:voltage?; measure:power?');
% Write Data_string in vector of type struct
Data_eLOAD_string_vec{i} = Data_eLOAD_string;
toc
while(toc < T_smpl) % define Sampling time (0.1s)
;
end
Set_pointStr = int2str(Amp) save ( ['Test_',Set_pointStr,'_Amp' '.mat'], 'U_eLOAD','I_eLOAD')
in this code now I want to run it for 5 times for different 'Current' so I manually change the value. So now I want to make it automatic
Jan
Jan 2017년 11월 30일
@arvind: Remember, that I do not have any idea about what you are doing. Which variable is the 'Current'? What about using a FOR loop?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by