Printing a variable in a fprintf

118 Ansichten (letzte 30 Tage)
BP
BP am 5 Nov. 2021
I set this varaible number first thing at the top of the scrip.
VTL="5kV";
After it does the calculation, I want to use a fprintf to print that varable within the command line so it looks something like
The following are the 5kV circuit values
I am now using the following
fprintf('<strong> 5kV circuit values </strong>\n')
I want to automate this because I forget to go to the end of the code and update this fprintf line.
Please help.
Thanks,

Antworten (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 5 Nov. 2021
Bearbeitet: Sulaymon Eshkabilov am 5 Nov. 2021
This can be done in a relatively simple way.
VTL="5kV";
fprintf('Initial Value is: %s circuit values\n', VTL)
... % Your calculation codes come here:
VTL = rand(5, 1)*10;
fprintf('The followings are the 5kV circuit values: %f \n', VTL)
... % Your calculation codes come here:
VTL = VTL+rand(5,1)*5;
fprintf('The final values are: %f \n', VTL)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by