Related
I am new to PYMC3. Maybe this is a naive question, but I searched a lot and didn't find any explanation on this issue.
Basically, I want to do a linear regression in PYMC3, however the training is very slow and the model performance on training set is very poor as well. Below is my code:
X_Tr = np.array([ 13.99802212, 13.8512075 , 13.9531636 , 13.97432944,
13.89211468, 13.91357953, 13.95987483, 13.86476587,
13.9501789 , 13.92698143, 13.9653932 , 14.06663115,
13.91697969, 13.99629862, 14.01392784, 13.96495713,
13.98697998, 13.97516973, 14.01048397, 14.05918188,
14.08342002, 13.89350606, 13.81768849, 13.94942447,
13.90465027, 13.93969029, 14.18771189, 14.08631113,
14.03718829, 14.01836206, 14.06758363, 14.05243539,
13.96287123, 13.93011351, 14.01616973, 14.01923812,
13.97424024, 13.9587175 , 13.85669845, 13.97778302,
14.04192138, 13.93775494, 13.86693585, 13.79985956,
13.82679677, 14.06474544, 13.90821822, 13.71648423,
13.78899668, 13.76857337, 13.87201756, 13.86152949,
13.80447525, 13.99609891, 14.0210165 , 13.986906 ,
13.97479211, 14.04562055, 14.03293095, 14.15178043,
14.32413197, 14.2330354 , 13.99247751, 13.92962912,
13.95394525, 13.87888254, 13.82743111, 14.10724699,
14.23638905, 14.15731881, 14.13239278, 14.13386722,
13.91442452, 14.01056255, 14.19378649, 14.22233852,
14.30405399, 14.25880108, 14.23985258, 14.21184303,
14.4443183 , 14.55710331, 14.42102092, 14.29047616,
14.43712609, 14.58666212])
y_tr = np.array([ 13.704, 13.763, 13.654, 13.677, 13.66 , 13.735, 13.845,
13.747, 13.747, 13.606, 13.819, 13.867, 13.817, 13.68 ,
13.823, 13.779, 13.814, 13.936, 13.956, 13.912, 13.982,
13.979, 13.919, 13.944, 14.094, 13.983, 13.887, 13.902,
13.899, 13.881, 13.784, 13.909, 13.99 , 14.06 , 13.834,
13.778, 13.703, 13.965, 14.02 , 13.992, 13.927, 14.009,
13.988, 14.022, 13.754, 13.837, 13.91 , 13.907, 13.867,
14.014, 13.952, 13.796, 13.92 , 14.051, 13.773, 13.837,
13.745, 14.034, 13.923, 14.041, 14.077, 14.125, 13.989,
14.174, 13.967, 13.952, 14.024, 14.171, 14.175, 14.091,
14.267, 14.22 , 14.071, 14.112, 14.174, 14.289, 14.146,
14.356, 14.5 , 14.265, 14.259, 14.406, 14.463, 14.473,
14.413, 14.507])
sns.regplot(x=X_tr, y=y_tr.flatten());
Here I use PYMC3 to train the model:
shA_X = shared(X_tr)
with pm.Model() as linear_model:
alpha = pm.Normal("alpha", mu=14,sd=100)
betas = pm.Normal("betas", mu=0, sd=100, shape=1)
sigma = pm.HalfCauchy('sigma', beta=10, testval=1.)
mu = alpha + betas * shA_X
forecast = pm.Normal("forecast", mu=mu, sd=sigma, observed=y_tr)
step = pm.NUTS()
trace=pm.sample(3000, tune=1000)
and then check the performance:
ppc_w = pm.sample_ppc(trace, 1000, linear_model,
progressbar=False)
plt.plot(ppc_w['forecast'].mean(axis=0),'r')
plt.plot(y_tr, color='k')`
Why is the prediction on the training set so poor?
Any suggestions and ideas are appreciated.
This model is doing a fine job - I think the confusion is over how to handle the PyMC3 objects (thank you for the easy to work with example, though!). In general, PyMC3 will be used to quantify the uncertainty in your model.
For example, trace['betas'].mean() is around 0.83 (this will depend on your random seed), while the least squares estimate that, for example, sklearn gives will be 0.826. Similarly, trace['alpha'].mean() gives 2.34, while the "true" value is 2.38.
You can also use the trace to plot many different plausible draws for your line of best fit:
for draw in trace[::100]:
pred = draw['betas'] * X_tr + draw['alpha']
plt.plot(X_tr, pred, '--', alpha=0.2, color='grey')
plt.plot(X_tr, y_tr, 'o');
Note that these are drawn from the distribution of "best fits" for your data. You also used sigma to model the noise, and you can plot this value as well:
for draw in trace[::100]:
pred = draw['betas'] * X_tr + draw['alpha']
plt.plot(X_tr, pred, '-', alpha=0.2, color='grey')
plt.plot(X_tr, pred + draw['sigma'], '-', alpha=0.05, color='red')
plt.plot(X_tr, pred - draw['sigma'], '-', alpha=0.05, color='red');
plt.plot(X_tr, y_tr, 'o');
Using sample_ppc draws observed values from your posterior distribution, so each row of ppc_w['forecast'] is a reasonable way for the data to be generated "next time". You might use that object this way:
ppc_w = pm.sample_ppc(trace, 1000, linear_model,
progressbar=False)
for draw in ppc_w['forecast'][::5]:
sns.regplot(X_tr, draw, scatter_kws={'alpha': 0.005, 'color': 'r'}, fit_reg=False)
sns.regplot(X_tr, y_tr, color='k', fit_reg=False);
I am using MATLAB_R2016b.
I have data of this format
Temperature = [310:10:800];
Pressure = [0.1 0 1.0 10.0 100.0 1000.0];
Cv = ...
[ 73.6400 25.3290 73.5920 73.1260 69.4500 61.8600
72.8060 25.3810 72.7640 72.3450 68.9780 61.7040
71.9230 25.4380 71.8850 71.5070 68.4230 61.3140
71.0060 25.4990 70.9710 70.6290 67.8040 60.8160
70.0680 25.5640 70.0360 69.7270 67.1400 60.2840
69.1220 25.6340 69.0940 68.8140 66.4460 59.7550
68.1800 25.7070 68.1540 67.9000 65.7350 59.2500
27.6640 25.7840 67.2240 66.9940 65.0150 58.7780
27.3630 25.8640 66.3120 66.1040 64.2950 58.3390
27.1700 25.9480 65.4220 65.2330 63.5820 57.9340
27.0440 26.0340 64.5570 64.3850 62.8790 57.5600
26.9660 26.1230 63.7210 63.5640 62.1900 57.2130
26.9240 26.2150 62.9130 62.7700 61.5170 56.8890
26.9110 26.3090 62.1360 62.0050 60.8620 56.5870
26.9200 26.4050 61.3890 61.2690 60.2250 56.3020
26.9460 26.5030 33.1250 60.5620 59.6080 56.0320
26.9870 26.6030 31.8460 59.8850 59.0090 55.7750
27.0390 26.7050 31.0570 59.2360 58.4290 55.5290
27.1010 26.8080 30.5000 58.6170 57.8680 55.2920
27.1700 26.9120 30.0840 58.0280 57.3240 55.0630
27.2460 27.0170 29.7670 57.4700 56.7980 54.8410
27.3280 27.1240 29.5260 56.9450 56.2900 54.6250
27.4140 27.2320 29.3430 56.4560 55.7970 54.4150
27.5040 27.3410 29.2080 56.0070 55.3210 54.2090
27.5980 27.4500 29.1110 55.6040 54.8600 54.0080
27.6940 27.5610 29.0460 55.2610 54.4150 53.8100
27.7930 27.6720 29.0060 54.9970 53.9840 53.6160
27.8950 27.7840 28.9870 54.8470 53.5670 53.4260
27.9980 27.8970 28.9870 51.7540 53.1650 53.2390
28.1030 28.0110 29.0020 47.2710 52.7760 53.0550
28.2100 28.1250 29.0290 44.3160 52.4010 52.8750
28.3180 28.2400 29.0670 42.1390 52.0390 52.6980
28.4270 28.3550 29.1150 40.4520 51.6910 52.5230
28.5380 28.4710 29.1710 39.1070 51.3570 52.3520
28.6500 28.5880 29.2340 38.0170 51.0350 52.1840
28.7630 28.7060 29.3040 37.1240 50.7260 52.0200
28.8770 28.8240 29.3780 36.3870 50.4300 51.8580
28.9920 28.9420 29.4580 35.7750 50.1460 51.7000
29.1080 29.0610 29.5420 35.2640 49.8730 51.5440
29.2250 29.1810 29.6290 34.8380 49.6100 51.3930
29.3420 29.3010 29.7200 34.4810 49.3570 51.2440
29.4610 29.4220 29.8150 34.1820 49.1120 51.0990
29.5800 29.5440 29.9120 33.9330 48.8720 50.9570
29.6990 29.6660 30.0110 33.7250 48.6360 50.8190
29.8200 29.7880 30.1130 33.5540 48.4000 50.6830
29.9410 29.9110 30.2170 33.4130 48.1630 50.5520
30.0630 30.0340 30.3230 33.3000 47.9210 50.4230
30.1850 30.1580 30.4310 33.2100 47.6720 50.2990
30.3080 30.2820 30.5400 33.1400 47.4140 50.1770
30.4310 30.4070 30.6510 33.0890 47.1430 50.0590];
When I try to query a new [temperature, pressure] pair, for example [0.2, 341] by doing this
interp2(Temperature, Pressure, Cv, 0.2, 341)
I get the following error:
Error using griddedInterpolant
The grid vectors must be strictly monotonically increasing.
Error in interp2>makegriddedinterp (line 229)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 129)
F = makegriddedinterp({X, Y}, V, method,extrap);
What am I doing wrong? And how can I get the desired result?
You need to have the same number of points in Temperature and Pressure as you do in Cv. You can generate these points using meshgrid.
[Temp, Pres] = meshgrid(Temperature, Pressure)
% Temp and Pres are both 6x50 matrices
However, you still have an issue. Temperature and Pressure must be monotonically increasing, as the error message states. This means you can't have a pressure value go down, which it does. You must change the second value in the Pressure array, or for instance you may want to swap columns 1 and 2 of the Pressure and Cv arrays
Pressure = [0.1, 0, 1, 10, 100, 1000]; % original
Pressure = Pressure([2, 1, 3:end]); % swap columns 1 and 2, Pressure = [0,0.1,1,10,...]
Cv = [...]; % All of your data
Cv = Cv(:, [2, 1, 3:end]) % Swap columns 1 and 2
Now you can do your lookup. Note you also had the temperature and pressure values the wrong way around, they must be the same order for inputs 1/2 and inputs 4/5.
[Temp, Pres] = meshgrid(Temperature, Pressure);
out = interp2(Temp, Pres, Cv.', 341, 0.2) % not (..., 0.2, 341) as must be same order
>> out = 30.5468
The only consideration you might want to give is that you're using linear interpolation with interp2, but your pressure data is logarithmic. Check your results are sensible.
How do I label each vector of each input component, say u$_1$..., d$_1$..., on my graph at each vector's respective starting point. I want to see if there is a clustering of certain vectors like u$_30$-u$_50$ are all near each other, for example. Here is my code:
fx = [1.01, 1.0165376460248143, 1.016585505356985,...
1.0166786731186357, 1.0166445649045002, 1.01684528204491,...
1.0168363943981442, 1.0169505828006045, 1.0169903647693619,...
1.0170588800755562, 1.0170214556321182, 1.0171007103163394,...
1.0170611565299144, 1.0171737504115423, 1.0171325089936156,...
1.0173884633568437, 1.0173821295549914, 1.017540453473392,...
1.0176091468862674, 1.0177647297690604, 1.017711866139699,...
1.0177536635811828, 1.0178254876275734, 1.0173994306983212,...
1.0200331803664529, 1.0232411092365432, 1.0232773133875106,...
1.023383936276914, 1.0233275057530007, 1.023510835824228,...
1.0234461433923472, 1.023507118352957, 1.0237210297124908,...
1.0236390252916325, 1.0237007559499636, 1.0239084387662698,...
1.0238131746118633, 1.024266374303865, 1.024212732428539,...
1.02440393427416, 1.0245390401237269, 1.0252178000353167,...
1.0252021019242434, 1.0275875709904758, 1.0275871039342042];
fy = [0.99, 0.99, 0.9899194500620327, 0.9897134368447225,...
0.9899339650105077, 0.9895259027418399, 0.9898115223446341,...
0.9896762515189842, 0.9896129792784014, 0.9894766621994305,...
0.9896189382715079, 0.9894614440540032, 0.9896292673356496,...
0.9894095770062209, 0.989655005387203, 0.9892019096930893,...
0.9894189058876284, 0.9892732425545386, 0.9891916768216495,...
0.9889512723219249, 0.9892071461243063, 0.9891515372181835,...
0.9890346980816267, 0.9901802532401042, 0.9892771992437573,...
0.9881487558751526, 0.9880037699743045, 0.9875669935217211,...
0.9878502051001951, 0.9872010568874899, 0.9875329139453003,...
0.9873775054641964, 0.9868251990627905, 0.9871082986923524,...
0.9869819983991632, 0.9865548473263468, 0.9867867860622922,...
0.9859765136441385, 0.9861731333993694, 0.9859212446482857,...
0.9857475603282838, 0.9848759880952044, 0.9850648602644492,...
0.9821891156159342, 0.9822254068452594];
fz =[0.01, -0.0014683388934621459, -0.0028093690242636917,...
-0.006255424514110392, -0.002405171080788649, -0.009167776104980133,...
0.0003750210183572269, -0.001823375333180016, -0.002906415137850454,...
-0.005227263048381278, -0.0028662319950483552, -0.0055329993182467365,...
-0.0027458980004112996, -0.00644276568444028, -0.00226410433801184,...
-0.009832266892691467, 0.0012478354917326469, -0.001163969711179093,...
-0.0026270200357900887, -0.006946260715800828, -0.00188587841967576,...
-0.002880843788516535, -0.0049636661241180685, 0.015586949435911355,...
0.010368914010693711, -0.0010649331940053245, -0.002328942248654949,...
-0.006634620630021168, -0.0020052485893380344, -0.008543368794125199,...
-0.00044976575279103564, -0.0019790036016751333, -0.008330963679008077,...
-0.0006481277669472506, -0.0020539789179887767, -0.0075781311330381336,...
-0.001294365366809558, -0.011629381859506432, 0.003447063734076782,...
0.0011256038145771368, -0.0008637305140054806, -0.012865086502170518,...
0.005283762238371167, -0.016926299226379265, 0.011993515880473204];
x = [1.01, 1.0165376460248143, 1.016585505356985, 1.0166786731186357,...
1.0166445649045002, 1.01684528204491, 1.0168363943981442,...
1.0169505828006045, 1.0169903647693619, 1.0170588800755562,...
1.0170214556321182, 1.0171007103163394, 1.0170611565299144,...
1.0171737504115423, 1.0171325089936156, 1.0173884633568437,...
1.0173821295549914, 1.017540453473392, 1.0176091468862674,...
1.0177647297690604, 1.017711866139699, 1.0177536635811828,...
1.0178254876275734, 1.0173994306983212, 1.0200331803664529,...
1.0232411092365432, 1.0232773133875106, 1.023383936276914,...
1.0233275057530007, 1.023510835824228, 1.0234461433923472,...
1.023507118352957, 1.0237210297124908, 1.0236390252916325,...
1.0237007559499636, 1.0239084387662698, 1.0238131746118633,...
1.024266374303865, 1.024212732428539, 1.02440393427416,...
1.0245390401237269, 1.0252178000353167, 1.0252021019242434,...
1.0275875709904758, 1.0275871039342042];
y = [0.99, 0.99, 0.9899194500620327, 0.9897134368447225,...
0.9899339650105077, 0.9895259027418399, 0.9898115223446341,...
0.9896762515189842, 0.9896129792784014, 0.9894766621994305,...
0.9896189382715079, 0.9894614440540032, 0.9896292673356496,...
0.9894095770062209, 0.989655005387203, 0.9892019096930893,...
0.9894189058876284, 0.9892732425545386, 0.9891916768216495,...
0.9889512723219249, 0.9892071461243063, 0.9891515372181835,...
0.9890346980816267, 0.9901802532401042, 0.9892771992437573,...
0.9881487558751526, 0.9880037699743045, 0.9875669935217211,...
0.9878502051001951, 0.9872010568874899, 0.9875329139453003,...
0.9873775054641964, 0.9868251990627905, 0.9871082986923524,...
0.9869819983991632, 0.9865548473263468, 0.9867867860622922,...
0.9859765136441385, 0.9861731333993694, 0.9859212446482857,...
0.9857475603282838, 0.9848759880952044, 0.9850648602644492,...
0.9821891156159342, 0.9822254068452594];
z =[0.01, -0.0014683388934621459, -0.0028093690242636917,...
-0.006255424514110392, -0.002405171080788649, -0.009167776104980133,...
0.0003750210183572269, -0.001823375333180016, -0.002906415137850454,...
-0.005227263048381278, -0.0028662319950483552, -0.0055329993182467365,...
-0.0027458980004112996, -0.00644276568444028, -0.00226410433801184,...
-0.009832266892691467, 0.0012478354917326469, -0.001163969711179093,...
-0.0026270200357900887, -0.006946260715800828, -0.00188587841967576,...
-0.002880843788516535, -0.0049636661241180685, 0.015586949435911355,...
0.010368914010693711, -0.0010649331940053245, -0.002328942248654949,...
-0.006634620630021168, -0.0020052485893380344, -0.008543368794125199,...
-0.00044976575279103564, -0.0019790036016751333, -0.008330963679008077,...
-0.0006481277669472506, -0.0020539789179887767, -0.0075781311330381336,...
-0.001294365366809558, -0.011629381859506432, 0.003447063734076782,...
0.0011256038145771368, -0.0008637305140054806, -0.012865086502170518,...
0.005283762238371167, -0.016926299226379265, 0.011993515880473204];
figure
q = quiver3(fx,fy,fz,x,y,z)
The problem is that I want to label the starting point of each vector:
You can use text:
q = quiver3(fx,fy,fz,x,y,z)
text(fx,fy,fz,num2str((1:numel(fx)).'))
The first 3 inputs are the coordinates of the label and the next input is a list (column character array or a cell-array) of the labels. I don't understand how your labeling is working (i.e. what is u$_1$ or d$_1$), so I just numbered the vectors from 1 to 45.
I have the following matrix which rows are points sampled from a function
f = [ -3.7850 -11.5240
-3.7753 -11.4822
-3.7680 -11.5427
-3.7592 -11.5607
-3.7576 -11.5461
-3.7454 -11.5887
-3.7386 -11.4070
-3.7358 -11.4450
-3.7289 -11.5511
-3.7254 -11.3713
-3.7122 -11.4515
-3.6820 -11.5582
-3.6758 -11.5946
-3.6732 -11.5823
-3.6679 -11.6365
-3.6487 -11.3525
-3.6424 -11.2745
-3.6322 -11.3478
-3.6235 -11.6379
-3.6159 -11.6308
-3.5619 -11.1980
-3.5550 -11.2284
-3.5544 -11.5925
-3.5147 -11.6578
-3.5041 -11.6756
-3.4860 -11.1550
-3.4654 -11.6341
-3.4550 -11.1329
-3.3802 -11.6701
-3.3691 -11.1083
-3.3541 -11.0790
-3.3485 -11.5887
-3.3006 -11.6384
-3.2481 -11.5570
-3.2459 -11.0268
-3.2441 -10.9314
-3.2301 -11.5225
-3.2270 -10.8832
-3.1543 -10.8612
-3.1528 -11.5490
-3.1167 -11.5021
-3.1102 -10.8255
-3.0645 -11.5618
-2.9967 -11.5420
-2.9898 -10.8136
-2.9645 -10.7107
-2.9211 -11.4197
-2.9175 -10.6389
-2.8558 -10.6015
-2.8327 -11.5108
-2.7768 -11.4501
-2.7392 -10.5492
-2.7217 -11.4230
-2.6988 -10.4724
-2.6235 -11.3226
-2.6196 -11.3806
-2.5772 -10.4518
-2.5458 -10.4317
-2.5014 -10.3176
-2.4832 -11.3822
-2.4778 -10.2456
-2.4029 -11.2907
-2.3723 -10.3002
-2.3590 -11.2911
-2.3491 -10.2110
-2.2756 -11.2318
-2.2554 -10.1204
-2.2542 -10.1411
-2.2181 -11.2300
-2.1982 -9.9584
-2.1645 -9.7938
-2.1541 -11.1682
-2.1476 -9.8235
-2.1451 -9.9205
-2.1280 -10.0064
-2.1269 -9.8947
-2.0898 -9.7926
-2.0781 -11.1293
-1.9985 -11.0985
-1.9249 -11.0443
-1.8220 -11.0419
-1.7359 -11.0043
-1.6924 -10.9775
-1.6049 -10.9579
-1.5275 -10.9339
-1.4757 -10.9113
-1.4122 -10.8854
-1.3245 -10.8908
-1.2936 -10.7893
-1.2091 -10.8121
-1.1575 -10.8064
-1.1237 -10.7105
-1.0571 -10.7724
-1.0217 -10.7096
-0.9717 -10.6984
-0.9447 -10.7103
-0.9120 -10.6687
-0.8908 -10.6670]
Plotting by plot(f(:,1),f(:,2),'+') it is clear that the function has a V-shape. However, I need to plot it continuously, but doing plot(f(:,1),f(:,2)) results in a zig-zag function. How can I plot the points as I want to? (beside sorting them manually)
You could try rotating your data, sorting it and rotating it back. e.g:
theta = -1;
R = [cos(theta) -sin(theta);sin(theta) cos(theta)];
f2 = f*R;
f3 = sortrows(f2);
f4 = f3*R';
plot(f4(:,1),f4(:,2),'-',f(:,1),f(:,2),'+')
You can tweak theta to change the angle, which affects the sort order, I just took a guess that -1 is about right.
I have a Output Curve of following characteristics
http://i.imgur.com/hABfsiC.jpg
Following is the data which represents the output curve cited above
0 1228.15406117455 1213.71796132282 1199.44623423626 1185.33715849069 1171.38902630825 1157.60014358826 1143.96882993237 1130.49341866405 1117.17225684288 1104.00370527364 1090.98613851046 1078.11794485629 1065.39752635781 1052.82329879590 1040.39369167202 1028.10714819050 1015.96212523702 1003.95709335331 992.090536708388 980.360953066379 968.766853751044 957.306763607236 945.979220959370 934.782777567031 923.715998577884 912.777462477973 901.965761039541 891.279499266498 880.717295337626 870.277780547640 859.959599246218 849.761408775075 839.681879403208 829.719694260385 819.873549268974 810.142153074209 800.524226972966 791.018504841132 781.623733059661 772.338670439371 763.162088144576 754.092769615612 745.129510490332 736.271118524637 727.516413512102 718.864227202765 710.313403221133 701.862796983477 693.511275614446 685.257717863085 677.101014018280 669.040065823703 661.073786392290 653.201100120311 645.420942601057 637.732260538220 630.134011658968 622.625164626790 615.204698954125 607.871604914830 600.624883456507 593.463546112736 586.386614915240 579.393122306018 572.482111049470 565.652634144552 558.903754736983 552.234546031533 545.644091204419 539.131483315831 532.695825222615 526.336229491134 520.051818310328 513.841723405001 507.705085949342 501.641056480713 495.648794813713 489.727469954538 483.876260015660 478.094352130827 472.380942370417 466.735235657145 461.156445682143 455.643794821435 450.196514052799 444.813842873049 439.495029215736 434.239329369281 429.046007895553 423.914337548901 418.843599195643 413.833081734033 408.882082014698 403.989904761570 399.155862493301 394.379275445192 389.659471491612 384.995786068946 380.387562099043 375.834149913207 371.334907176693 366.889198813755 362.496396933217 358.155880754588 353.867036534721 349.629257495012 345.441943749158 341.304502231452 337.216346625644 333.176897294352 329.185581209025 325.241831880470 321.345089289941 317.494799820775 313.690416190604 309.931397384121 306.217208586402 302.547321116805 298.921212363411 295.338365718043 291.798270511836 288.300421951372 284.844321055367 281.429474591926 278.055395016351 274.721600409499 271.427614416707 268.172966187255 264.957190314395 261.779826775920 258.640420875285 255.538523183269 252.473689480189 249.445480698649 246.453462866826 243.497207052304 240.576289306430 237.690290609210 234.838796814729 232.021398597103 229.237691396949 226.487275368383 223.769755326528 221.084740695544 218.431845457169 215.810688099765 213.220891567874 210.662083212278 208.133894740554 205.635962168130 203.167925769835 200.729430031931 198.320123604641 195.939659255160 193.587693821135 191.263888164634 188.967907126584 186.699419481673 184.458097893730 182.243618871551 180.055662725203 177.893913522768 175.758059047548 173.647790755713 171.562803734401 169.502796660248 167.467471758370 165.456534761766 163.469694871160 161.506664715267 159.567160311482 157.650901026989 155.757609540290 153.887011803139 152.038837002892 150.212817525260 148.408688917462 146.626189851781 144.865062089509 143.125050445289 141.405902751840 139.707369825069 138.029205429564 136.371166244459 134.733011829684 133.114504592569 131.515409754832 129.935495319916 128.374532040696 126.832293387534 125.308555516696 123.803097239110 122.315699989477 120.846147795722 119.394227248782 117.959727472736 116.542440095264 115.142159218437 113.758681389832 112.391805573974 111.041333124092 109.707067754198 108.388815511474 107.086384748976 105.799586098638 104.528232444585 103.272138896747 102.031122764767 100.805003532210 99.5936028310572 98.3967444164976 97.2142541419957 96.0459599346504 94.8916917708293 93.7512816520819 92.6245635813268 91.5113735393103 90.4115494613329 89.3249312142428 88.2513605736907 87.1906812016462 86.1427386241704 85.1073802094438 84.0844551460460 83.0738144214844 82.0753108009696 81.0887988064351 80.1141346957970 79.1511764424544 78.1997837150241 77.2598178573099 76.3311418685023 75.4136203836077 74.5071196541023 73.6115075288110 72.7266534350062 71.8524283597264 70.9887048313103 70.1353569011454 69.2922601256279 68.4592915483322 67.6363296823873 66.8232544930576 66.0199473805265 65.2262911628803 64.4421700592893 63.6674696733859 62.9020769768354 62.1458802930985 61.3987692813833 59.4883213755835 57.6483869118112 55.8755259367794 54.1665202384763 52.5183563982524 50.9282102384589 49.3934325474650 47.9115359739955 46.4801829919653 45.0971748454356 43.7604413910364 42.4680317622626 41.2181057864981 40.0089260915283 38.8388508436906 37.7063270647464 36.6098844790632 35.5481298468222 34.5197417427304 33.5234657431651 32.5581099878283 31.6225410848696 30.7156803310698 29.8365002210865 28.9840212219663 28.1573087911403 27.3554706179645 26.5776540705486 25.8230438311588 25.0908597048888 24.3803545875820 23.6908125801659 23.0215472376397 22.3718999419403 21.7412383888150 21.1289551796556 20.5344665100015 19.9572109471129 19.3966482896451 18.8522585030342 18.3235407247356 17.8100123339373 17.3112080808174 16.8266792708190 16.3559929997865 15.8987314361504 15.4544911466551 15.0228824624129 14.6035288823265 14.1960665111621 13.8001435297733 13.4154196951792 13.0415658683801 12.6782635679663 12.3252045477276 11.9820903966137 11.6486321595240 11.3245499775272 11.0095727462157 10.7034377910043 10.4058905582723 10.1166843213306 9.83557990027752 9.56234539487254 9.29675592962605 9.03859341036164 8.78764629156238 8.54370935386321 8.30658349109817 8.07607550635358 7.85199791651758 7.63416876485290 7.42241144115244 7.21655450906823 7.01643154023247 6.82188095481515 6.63274586818697 6.44887394337809 6.27011724904377 6.09633212266684 5.92737903874406 5.76312248171972 5.60343082344452 5.44817620495165 5.29723442235448 5.15048481668219 5.00781016748056 4.86909659001510 4.73423343592343 4.60311319717196 4.47563141318063 4.35168658098654 4.23118006832444 4.11401602950876 4.00010132400749 3.88934543760435 3.78166040605072 3.67696074111369 3.57516335893142 3.47618751059112 3.37995471484913 3.28638869291620 3.19541530523493 3.10696249017925 3.02096020460939 2.93734036621838 2.85603679760903 2.77698517204319 2.70012296080697 2.62538938213866 2.55272535166765 2.48207343431511 2.41337779760910 2.34658416636844 2.28163977871173 2.21849334334935 2.15709499811800 2.09739626971883 2.03935003462156 1.98291048109845 1.92803307235332 1.87467451071194 1.82279270284141 1.77234672596718 1.72329679505757 1.67560423094658 1.62923142936686 1.58414183086548 1.54029989157635 1.49767105482374 1.45622172353228 1.41591923341968 1.37673182694912 1.33862862801892 1.30157961736815 1.26555560867691 1.23052822534142 1.19646987790401 1.16335374211922 1.13115373763752 1.09984450728875 1.06940139694817 1.03980043596818 1.01101831815952 0.983032383306248 0.955820599199133 0.929361544172696 0.903634390131477 0.878618886051614 0.854295341944170 0.830644613267103 0.807648085773110 0.785287660780989 0.763545740858505 0.742405215905110 0.721849449623219 0.701862266367018 0.682427938358193 0.663531173258183 0.645157102086936 0.627291267478379 0.609919612263140 0.593028468369314 0.576604546032312 0.560634923305132 0.545107035860604 0.530008667077409 0.515327938401923 0.501053299978151 0.487173521538225 0.473677683546191 0.460555168587976 0.447795653000654 0.435389098734315 0.423325745440032 0.411596102777619 0.400190942937019 0.389101293367371 0.378318429707958 0.367833868915394 0.357639362581574 0.347726890437081 0.338088654034864 0.328717070609165 0.319604767104817 0.310744574372160 0.302129521522970 0.293752830442904 0.285607910456123 0.277688353137837 0.269987927270671 0.262500573940842 0.255220401770266 0.248141682280806 0.241258845386994 0.234566475013650 0.228059304834930 0.221732214131435 0.215580223762081 0.209598492247567 0.203782311962319 0.198127105431917 0.192628421733057 0.187281932993220 0.182083430987262 0.177028823828250 0.172114132749923 0.167335488978228 0.162689130689473 0.158171400052687 0.153778740353848 0.149507693199712 0.145354895799043 0.141317078319080 0.137391061315172 0.133573753231541 0.129862147971212 0.126253322533180 0.122744434714959 0.119332720878702 0.116015493779123 0.112790140451515 0.109654120158199 0.106604962391776 0.103640264933625 0.100757691966098 0.0979549722369389 0.0952298972744753 0.0925803196521720 0.0900041513011877 0.0874993618696001 0.0850639771270087 0.0826960774132594 0.0803937961300688 0.0781553182743600 0.0759788790121574 0.0738627622919147 0.0718052994961873 0.0698048681305858 0.0678598905489812 0.0659688327139552 0.0641302029915237 0.0623425509791821 0.0606044663663534 0.0589145778263389 0.0572715519389033 0.0556740921426450 0.0541209377163267 0.0526108627883675 0.0511426753737151
The following function represents the output characteristics of Tracer in 50 minute time interval ( The Y-Axis-Mbq and X-Axis : Time in minutes)
Now i would like to Sample the Output Curve into 19 frames
4 frames : Each of 15 seconds time interval
2 frames : Each of 30 seconds time interval
2 frames : Each of 60 seconds time interval
11 frames : Each of 200 seconds time interval
and plot each of the Respective frames in a plot, kindly suggest me some methodology to approach this problem
If I understand correctly, you have for the corresponding x-values time from 0 to 50 minutes, so since you have 500 samples you have 10 samples per minute or an interval of 6 seconds between samples.
To get samples at a different rate, you can interpolate your signal using interp1. If the signal you gave above is stored in Y, you can interpolate it to 15 second intervals using:
x = 0:6:3000; % The original sample time, in seconds
xi = 0:15:3000; % The interpolated sample time, in seconds
Yi = interp1(x, Y, xi);
You can interpolate to any specified x-value within the original data, so for the varying sample rate you require you can define:
xi = [0:15:60, 90:30:120, 180:60:240, 440:200:2240];
Plotting of curves in MATLAB is usually done using the plot function. For your interpolated data you can use:
figure;
plot(xi / 60, Yi);
xlabel('Time [min]');
ylabel('Signal [units]');
title('My signal');
Note how the time units have been changed from seconds to minutes for the plot. The rest of the commands given here are useful for plotting as well. figure creates a new figure window for the plot and xlabel, ylabel and title are used to annotate it.