Modify then write data in the given format
Sie verfolgen jetzt diese Frage
- Aktualisierungen können Sie in Ihrem Feed verfolgter Inhalte sehen.
- Je nach Ihren Kommunikationseinstellungen können Sie auch E-Mails erhalten.
Es ist ein Fehler aufgetreten
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
0 Stimmen
Teilen Sie einen Link zu dieser Frage
1 Kommentar
Teilen Sie einen Link zu diesem Kommentar
Akzeptierte Antwort
0 Stimmen
Teilen Sie einen Link zu dieser Antwort
- Read the first three columns to one string, since they shall only be copied to the output file.
- Read the following six columns to a double array.
- Add 1 to the prescribed elements of the array
- Use the same format string to write the data (don't forget new-line)
27 Kommentare
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
- It's possible to read your example with textscan and a similar format specifier - see my addendum. Or are we speaking past each other?
- Can we be sure that "undocumented" behavior of textscan doesn't change between releases?
- "Somewhere some months ago"   might be this thread read ascii non-delimited file.
- "older Fortran and are still around"   that's true and most large "csv-files" contains fixed-width columns. Long time ago reading fixed-format text-files was much faster than reading free-format. Is that still the case?
- Rows with leading spaces causes problems. '%s' handles it, but '%f' doesn't.
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
- Regarding the documentation in general I think that it's okay and is being improved over time. However, I've have wishes. More elaborated problem oriented examples, e.g. "How to read fixed width text file" and "How to read multi-section text files". Easier to find a function when I forgotten the name. And more.
- textscan   Knowledge on C might helps to understand why, but must not be required. (If needed that should be clearly stated.) Regarding 'Delimiter','' and 'Whitespace','' I still think they don't cause the promised behavior. Recently, I read some documentation on Fortran format specifiers. We only want a small subset.
- The documentation of the low-level HDF5-functions is another example of referring to third party documentation. In this case I think it is okay.
- The documentation on Regular expressions is okay I think. However, I think more elaborated examples would be useful.
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
- the first one (with commas) is the best (i.e. most readable) and
- that something like this would fit better in the Matlab environment than a syntax, which mimics fortrans FORMAT
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
- Sure, it's just "syntactic sugar".
- Maybe, a syntax like this would be enough (with a fortran engine)
- I don't understand TMW
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
- reading with textscan together with a format-string based entirely on %wc where w is a whole number
- format-string according to my comment above
- converting to numerical in a second step - maybe with str2num.
- do some timing experiments
- Is there a need for a new function to read fixed-formatted text files?
- Does my prototype handle the most frequent types of fixed-width files?
- A good fortran-mex-function, how much faster would that be?
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
- On input, the F data edit descriptor transfers w characters from an external field and assigns their real value to the corresponding I/O list item. The external field data must be an integer or real constant.
- If the input field contains only an exponent letter or decimal point, it is treated as a zero value.
- If the input field does not contain a decimal point or an exponent, it is treated as a real number of w digits, with d digits to the right of the decimal point. (Leading zeros are added, if necessary.)
- If the input field contains a decimal point, the location of that decimal point overrides the location specified by the F descriptor.
- If the field contains an exponent, that exponent is used to establish the magnitude of the value before it is assigned to the list element.
- An explicit 1X to skip the delimiter, or
- A compiler-dependent extension that recognizes the comma as a delimiter(*)
Teilen Sie einen Link zu diesem Kommentar
Teilen Sie einen Link zu diesem Kommentar
- Nobody would read them, and
- It would take a "language lawyer" to parse the result in the exotic cases if did.
Weitere Antworten (0)
Kategorien
Mehr zu Sudoku finden Sie in Hilfe-Center und File Exchange
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
