Matlab programming question on while loop

2 views (last 30 days)
In the below program the while loop is being executed, but I need to get the changed value of "a" in this line fprintf(dc1, 'SOUR:CURR a') but I am not getting it, could you please help me with this.
It is executing while loop and changing a value from 1 to 3 in increments of 0.5 but in this line fprintf(dc1, 'SOUR:CURR a'); the value of "a" always shows 1. Please advise.
a=1;
while a<=3
fprintf(dc1, 'SOUR:CURR a');
fprintf(dc1, 'SOUR:CURR?');
idn_dc1current = fscanf(dc1)
fprintf(dc1, 'FETC:POW?');
idn_dc1power = fscanf(dc1)
a=a+0.5
end
Thank you and appreciate your help in advance. Hemanth

Answers (1)

Image Analyst
Image Analyst on 28 Feb 2015
Maybe you want
fprintf(dc1, 'SOUR:CURR %0.1f', a) ;
hard to say because it's doing exactly what you tell it rather than what you want. But if you want the value of a printed to the file, then do that.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!