Plot graph from Text data

1 回表示 (過去 30 日間)
Aike
Aike 2011 年 8 月 21 日
Dear Sir,
I have Text data which part of data was shown below:
-197 -196 -187 -172 -174
-173 -157 -135 -112 -106
-106 -98 -100 -106 -107
-119 -122 -100 -86 -109
-122 -95 -80 -84 -75
-37 -20 -29 -16 4
23 33 44 67 80
100 113 103 107 128
138 126 116 112 98
76 50 44
-1 -23 -48 -76 -102
-121 -142 -159 -188 -221
-245 -274 -284 -291 -309
-305 -296 -312 -331 -320
-313 -322 -311 -288 -262
-252 -251 -237 -230 -229
-220 -209 -189 -170 -169
-177 -189 -188 -188 -194
-196 -207 -209 -205 -205
-206 -205 -210 -211 -189
-174 -172 -161 -155 -162
-169
-189 -183 -165 -143 -129
-120 -108 -84 -59 -42
-26 -4 28 54 71
96 121 137 131 118
120 123 131 128 100
71 64 63 49 38
The sampling rate of data was 20Hz that started at 00:00:00UT. But I don't know the end of time of sampling rate. Can you help me plot a graph from this data? The x axis should be time (UT) and y axis should be data as above. We should begin from the first row to the last row. Thank you very much.
Regards, Aike

回答 (3 件)

Fangjun Jiang
Fangjun Jiang 2011 年 8 月 22 日
Take a look at the data again. There are blank spot in a few places. Are they supposed to be that way, or are they some type of line wrapping errors?
You can use importdata() to read the data. It fills NaN for those blank spots. It's also easy to tell how many rows are in the data using function size(data,1). Then, since the sample rate is fixed, it's pretty easy to generate the time stamps. You could do some extra to get the actual time, 00:00:01UT for example, instead of 1 second in the below example.
y=importdata('test.txt');
f=20;
ts=1/f;
x=ts*(1:size(y,1));
plot(x,y)

shravankumar
shravankumar 2011 年 8 月 22 日
hi,
you can also use y=dlmread('test.txt'). I think it takes the blank elements as zero and gives a continuous curve.
shravan.

Aike
Aike 2011 年 8 月 22 日
Thank you for all suggestions. I already solved my problem from you all suggestions. Thank you very much.
Aike

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by