Hi friends,
I would like to know about loading .txt files in matlab. The vector data i have is given as a row for which i would like to calculate mean and other stats..
Kindly suggest me a way for that..
Thanks, Aishwarya
Hi friends,
I would like to know about loading .txt files in matlab. The vector data i have is given as a row for which i would like to calculate mean and other stats..
Kindly suggest me a way for that..
Thanks, Aishwarya
Given the file csvlist.dat that contains the comma-separated values
02, 04, 06, 08, 10, 12
03, 06, 09, 12, 15, 18
05, 10, 15, 20, 25, 30
07, 14, 21, 28, 35, 42
11, 22, 33, 44, 55, 66
To read the entire file, use
csvread('csvlist.dat')
ans =
2 4 6 8 10 12
3 6 9 12 15 18
5 10 15 20 25 30
7 14 21 28 35 42
11 22 33 44 55 66
Or you can use importdata.
If you have a txt file with row vector data that look like:
3.4
-4.1
1.5
-3
...
Then you can simply use:
data = load('file.txt'); #% load file
N = length(data); #% number of elements
mu = mean(data); #% mean
sigma = std(data); #% standard deviation
plot(data) #% simple plot