How to import data from .txt file?
385 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Benjamin Watson
il 13 Apr 2016
Commentato: Jan Babiuch-Hall
il 3 Mag 2022
Hi All,
Ive tried importing my data via this code;
Spill = importdata('Spill.txt');
T = Spill(:,1);
C = Spill(:,2);
plot(T,C)
xlabel('Time / Days');
ylabel('Concentration / ppb')
but it doesn't work as it says "Index exceeds matrix dimensions.". It needs to be inputted by code and not just the import button. Can someone help? Ive attached the .txt file
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 13 Apr 2016
Modificato: Azzi Abdelmalek
il 13 Apr 2016
Spill1 = importdata('Spill.txt');
Spill=Spill1.data
T = Spill(:,1);
C = Spill(:,2);
plot(T,C)
xlabel('Time / Days');
ylabel('Concentration / ppb')
0 Commenti
Più risposte (2)
parham kianian
il 2 Set 2020
I think it is much easier to use textread function. Following link describe in full detail how to use this function to import data from a text file:
Vedere anche
Categorie
Scopri di più su Data Import and Analysis in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!