How to import data from .txt file?
363 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Azzi Abdelmalek
2016-4-13
编辑:Azzi Abdelmalek
2016-4-13
Spill1 = importdata('Spill.txt');
Spill=Spill1.data
T = Spill(:,1);
C = Spill(:,2);
plot(T,C)
xlabel('Time / Days');
ylabel('Concentration / ppb')
0 个评论
更多回答(2 个)
parham kianian
2020-9-2
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:
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!