Problems with reading values from a structure

2 ビュー (過去 30 日間)
Trevor
Trevor 2016 年 9 月 23 日
回答済み: Michael Abboud 2016 年 9 月 27 日
I am working on a homework assignment, the goal of the assignment is to read values from a cf file into a structure and then write these values into a new cf file. I have looked at the structure and confirmed that the values are all being read correctly but they are writing to the new cf file incorrectly.
fprintf(fcf,' %5.3f',(S.Bus.voltspu(ii)));
fprintf(fcf,' ');
The value for voltspu is 1.005, but in the new cf file it shows up as 49.000. I am not sure what I am doing incorrectly. Thank you for your help!

回答 (1 件)

Michael Abboud
Michael Abboud 2016 年 9 月 27 日
If this code is printing the wrong value into your CF file, then it would seem your variable value may be incorrect. Try saving your variable to a temporary variable and printing that to the command window to see if it has the expected value. Then print that temporary variable to the file using the following commands:
>> myValue = S.Bus.voltspu(ii);
>> display(value);
>> fprintf(fcf, ' %5.3f', myValue);
>> fprintf(fcf, ' ');

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by