I wish to know how to automatically draw a constant current , each time the program runs.
2 次查看(过去 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
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 个评论
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 Center 和 File Exchange 中查找有关 Instrument Control Toolbox Supported Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!