Convert to fixed values and replace N/A with zero?

2 ビュー (過去 30 日間)
Adeline War
Adeline War 2022 年 7 月 6 日
コメント済み: dpb 2022 年 7 月 9 日
How do I convert this data to fixed values and replace N/A with zero?
  6 件のコメント
dpb 2022 年 7 月 9 日
Specifically what format do you consider a "real" number? And where is this formatting to take effect -- at command line (see format for that) or writing an output file or...???



Pratyush Swain
Pratyush Swain 2022 年 7 月 6 日
I believe by "converting to fixed number" you are trying to convert the scientic notation to real number notation.
%read the data%(This automatically coverts the numbers from scientic notation to floating point)
%fill missing data%
%write the table data to new file%
So the above 3 lines entails the following process
1-Sample Data
2-Imported table data after reading
3-Fill missing values
4-Write updated values to file
Hope this helps.
  4 件のコメント
dpb 2022 年 7 月 9 日
Nonsense. Read the doc on referencing table variables. See <table> and <Access Data in Tables>, the latter is a link in the preceding doc for table that shows how to use one once you have it.
You really wouldn't think TMW would build the table class and have no way in which to reference it, would you? There is a "veritable plethora" of addressing options and additional functionality associated with the table and timetable classes--but you've got to spend a little effort on your own and read/study the documentation for syntax and then look at the example code for illustration and to get an idea about some of the features that are therein.
And, don't overlook the links at the top of the doc page on Functions and the See Also section at the bottom of the page that shows you the most closely related other functions you're likely to find useful if you're using the specific function.


その他の回答 (2 件)

Rik 2022 年 7 月 6 日
Perhaps the strrep function does what you need.
data=strrep(data,'N/A',' 0')
data = 30×1 string array
"id,value" "44, 0.000E+00" "526, 6.464E-03" "527, 0.000E+00" "529, 0.000E+00" "530, 6.332E-03" "532, 6.838E-03" "542, 0.000E+00" "886, 0" "887, 0" "888, 0" "889, 0" "890, 0" "891, 0" "892, 0" "893, 5.030E-03" "894, 0" "895, 7.226E-03" "896, 8.863E-03" "897, 0" "898, 7.015E-03" "899, 6.572E-03" "900, 0" "901, 0" "902, 6.896E-03" "903, 6.118E-03" "904, 0" "905, 0" "906, 0" "1047, 0.000E+00"
  2 件のコメント
dpb 2022 年 7 月 9 日
Read the data file as numeric to begin with and you won't need to.
But, we just solved that problem in the other topic -- "split" if there were some real reason (hard to imagine what it would be) to read as text.
You can always write the numeric data back out in text files; there's no sense in making working with numeric data in memory more difficult than needs be.


dpb 2022 年 7 月 6 日
As @Rik, I have no klew what fixed values are to be, but the other Q? is trivial --
  1. Brute force...
2. Use builtin paramters on input...

Community Treasure Hunt

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

Start Hunting!

Translated by