WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Reading Textfile

 

Filomena
Forum-Newbie

Forum-Newbie


Beiträge: 5
Anmeldedatum: 10.04.20
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 10.04.2020, 11:23     Titel: Reading Textfile
  Antworten mit Zitat      
Hey everyone,
I´m very beginner at Matlab and have some trouble with opening a textfile and cant´t find the mistake in my code..the textfile Information just doesnt open up.
I have to sort the textfile (4 rows and 4 columns) in 4 categories, and this is what I tried:

(I already added the textfile to the path)

Code:

fopen ('exercise.txt');
fid = fopen ('C:\exercise.txt','r+');
Format = {'Subject' 'Condition' 'Iteration' 'Score'};
C = textscan( fid, 'Format' );
fclose (fid)
 


Can you maybe see why it doesnt open the textfile content? I´m very stuck, thank you so much Smile

exercise.txt
 Beschreibung:

Download
 Dateiname:  exercise.txt
 Dateigröße:  54 Bytes
 Heruntergeladen:  161 mal
Private Nachricht senden Benutzer-Profile anzeigen


Harald
Forum-Meister

Forum-Meister


Beiträge: 24.448
Anmeldedatum: 26.03.09
Wohnort: Nähe München
Version: ab 2017b
     Beitrag Verfasst am: 10.04.2020, 11:49     Titel:
  Antworten mit Zitat      
Hi,

first recommendation: read the doc! The format syntax you are trying to use is nothing close to what is shown in the examples for textscan.

Then, use tables. It's the most intuitive way to represent tabular data.
Code:
T = readtable("exercise.txt", "ReadVariableNames",false);
T.Properties.VariableNames = {'Subject' 'Condition' 'Iteration' 'Score'}


To systematically learn the basics of MATLAB, consider going through MATLAB Onramp.
https://www.mathworks.com/learn/tutorials/matlab-onramp.html

This is a German language forum, thus if you speak German, please write in German.

Cheers,
Harald
_________________

1.) Ask MATLAB Documentation
2.) Search gomatlab.de, google.de or MATLAB Answers
3.) Ask Technical Support of MathWorks
4.) Go mad, your problem is unsolvable ;)
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2024 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.