I have a a matrix Number which contains
0.2728 0.2304 0.2008 0.1900 0.2008 0.2304 0.2728
0.2304 0.1786 0.1391 0.1233 0.1391 0.1786 0.2304
0.2008 0.1391 0.0843 0.0567 0.0843 0.1391 0.2008
0.1900 0.1233 0.0567 0.0100 0.0567 0.1233 0.1900
0.2008 0.1391 0.0843 0.0567 0.0843 0.1391 0.2008
0.2304 0.1786 0.1391 0.1233 0.1391 0.1786 0.2304
0.2728 0.2304 0.2008 0.1900 0.2008 0.2304 0.2728
I am trying to find the minimum value (or values if there are equal mins).
I have tried
[min_val,idx]=min(number);
[row,col]=ind2sub(size(number),idx);
I am getting row 4 which is right but col 1 which clearly not the min, min is in the center.
When I print min(number) I am give the whole of row 4 so I also tried
[min_val,idx]=min(min(number));
[row,col]=ind2sub(size(number),idx);
But i's giving the same result. I'm not really sure what's going on here. Any help would be appreciated!
Code used to get the positions of multiple minimums.
[min_val, idx] = min(number(:));%finds minimum value of n
mins = number==min_val;%logical array that gives 1 where number is at
its minimum
ind1 = zeros();
ind2= zeros();
for i = 1:length(x)
for j = 1:length(y)
if min_val(i,j) == 1
ind1 = [ind1;i];% indcies where mins = 1
ind2 = [ind2;j];
end
end
end
ind1 = ind1(ind1~=0);
Looks like you can use min and ind2sub to achieve your expected output:
matlab:1> number = [0.2728 0.2304 0.2008 0.1900 0.2008 0.2304 0.2728; 0.2304 0.1786 0.1391 0.1233 0.1391 0.1786 0.2304; 0.2008 0.1391 0.0843 0.0567 0.0843 0.1391 0.2008; 0.1900 0.1233 0.0567 0.0100 0.0567 0.1233 0.1900; 0.2008 0.1391 0.0843 0.0567 0.0843 0.1391 0.2008; 0.2304 0.1786 0.1391 0.1233 0.1391 0.1786 0.2304; 0.2728 0.2304 0.2008 0.1900 0.2008 0.2304 0.2728]
number =
0.272800 0.230400 0.200800 0.190000 0.200800 0.230400 0.272800
0.230400 0.178600 0.139100 0.123300 0.139100 0.178600 0.230400
0.200800 0.139100 0.084300 0.056700 0.084300 0.139100 0.200800
0.190000 0.123300 0.056700 0.010000 0.056700 0.123300 0.190000
0.200800 0.139100 0.084300 0.056700 0.084300 0.139100 0.200800
0.230400 0.178600 0.139100 0.123300 0.139100 0.178600 0.230400
0.272800 0.230400 0.200800 0.190000 0.200800 0.230400 0.272800
matlab:2> [min_val, idx] = min(number(:))
min_val = 0.010000
idx = 25
matlab:3> [row, col] = ind2sub(size(number), idx)
row = 4
col = 4
Related
Here is my code:
sigma = 10;
sz = 20;
x = linspace(-sz / 2, sz / 2-1, sz);
gf = exp(-x .^ 2 / (2 * sigma ^ 2));
gf = gf / sum (gf); % normalize
f_filter = cconv(gf,f,length(f));
Basically I am Gaussian filtering original signal f. However, when I look at the filtered signal f_filter, there is a shift comparing the original signal f (See attached figure). I am not sure why this is happening. I would like to only smooth but not shift the orginal signal. Please help. Thanks.
my original signal f is here:
-0.0311
-0.0462
-0.0498
-0.0640
-0.0511
-0.0522
-0.0566
-0.0524
-0.0478
-0.0482
-0.0516
-0.0435
-0.0417
-0.0410
-0.0278
-0.0079
-0.0087
-0.0029
0.0105
0.0042
0.0046
0.0107
0.0119
0.0177
0.0077
0.0138
0.0114
0.0103
0.0089
0.0122
0.0122
0.0118
0.0041
0.0047
0.0062
0.0055
0.0033
0.0096
0.0062
-0.0013
0.0029
0.0112
0.0069
0.0160
0.0127
0.0131
0.0039
0.0116
0.0078
0.0018
0.0023
0.0133
0.0140
0.0135
0.0098
0.0100
0.0133
0.0131
0.0086
0.0114
0.0131
0.0175
0.0137
0.0157
0.0040
0.0136
0.0009
0.0049
0.0157
0.0104
0.0038
0.0039
0.0029
0.0126
0.0044
0.0055
0.0040
0.0091
-0.0023
0.0107
0.0151
0.0115
0.0135
0.0160
0.0071
0.0098
0.0094
0.0072
0.0079
0.0055
0.0155
0.0107
0.0108
0.0085
0.0099
0.0055
0.0078
0.0027
0.0121
0.0077
0.0062
0.0021
-0.0019
-0.0003
-0.0022
0.0059
0.0099
0.0114
0.0069
0.0038
0.0020
-0.0031
0.0024
-0.0025
-0.0004
0.0041
0.0059
0.0018
0.0033
0.0130
0.0131
0.0076
0.0084
0.0029
0.0086
0.0078
0.0054
0.0121
0.0101
0.0132
0.0115
0.0074
0.0070
0.0088
0.0017
-0.0003
-0.0060
0.0078
0.0100
0.0044
0.0017
0.0027
0.0062
0.0029
-0.0035
0.0032
0.0060
-0.0035
0.0081
0.0027
0.0043
0.0013
0.0049
0.0119
0.0273
0.0363
0.0435
0.0432
0.0357
0.0424
0.0318
0.0341
0.0354
0.0325
0.0263
0.0320
0.0312
0.0345
0.0407
0.0378
0.0376
0.0334
0.0381
0.0428
0.0375
0.0431
0.0403
0.0395
0.0308
0.0150
0.0006
0.0054
0.0002
0.0090
0.0075
0.0051
0.0067
0.0062
0.0108
0.0059
0.0095
0.0065
0.0087
0.0056
0.0136
0.0057
0.0079
0.0107
0.0106
0.0041
0.0032
0.0106
0.0091
0.0082
0.0025
0.0124
0.0035
0.0034
0.0097
0.0034
0.0050
0.0119
0.0087
0.0081
0.0118
0.0088
0.0050
0.0050
0.0057
0.0118
0.0122
0.0207
0.0112
0.0125
0.0083
0.0125
0.0140
0.0147
0.0237
0.0206
0.0141
0.0164
0.0189
0.0189
0.0136
0.0183
0.0195
0.0209
0.0154
0.0211
0.0254
0.0163
0.0249
0.0236
0.0262
0.0278
0.0285
0.0275
0.0212
0.0277
0.0211
0.0248
0.0289
0.0240
0.0266
0.0479
0.1744
0.4070
0.6818
0.8811
0.9859
0.9347
0.8441
0.7625
0.6396
0.4724
0.3639
0.3406
0.3406
0.3363
0.3318
0.3251
0.3287
0.3135
0.3122
0.3058
0.3103
0.3012
0.2974
0.2995
0.2941
0.2981
0.2968
0.2958
0.2938
0.2929
0.2926
0.2942
0.2982
0.2898
0.2940
0.2927
0.2950
0.2899
0.2979
0.2915
0.2961
0.2921
0.2931
0.2989
0.2941
0.2977
0.3041
0.3042
0.3086
0.3048
0.3069
0.3055
0.3123
0.3138
0.3128
0.3115
0.3092
0.3174
0.3152
0.3106
0.3080
0.3166
0.3109
0.3103
0.3135
0.3101
0.3133
0.3147
0.3044
0.2980
0.2972
0.3013
0.2980
0.3069
0.3932
0.6593
0.8921
1.1071
1.2763
1.3947
1.5076
1.6278
1.7452
1.7993
1.8287
1.8470
1.8957
1.9408
1.9791
2.0272
2.0686
2.0974
2.1335
2.1790
2.2134
2.2545
2.2903
2.3163
2.3585
2.3739
2.4126
2.4503
2.4787
2.5198
2.5447
2.5950
2.6228
2.6410
2.6812
2.7123
2.7557
2.8584
3.2480
3.5315
3.6808
3.7632
3.7471
3.7283
3.6692
3.6718
3.7756
3.9672
4.0376
3.9092
3.7276
3.6586
3.5948
3.6392
3.5671
3.6003
3.6194
3.6350
3.6624
3.6855
3.6958
3.9105
4.3880
5.1342
5.6176
6.3206
7.0392
7.3767
7.5715
7.6516
7.6469
7.5871
7.4591
7.6004
7.5532
7.3601
7.1487
5.9728
4.8974
4.5850
4.4268
4.3352
4.2887
4.3376
4.3182
4.2909
4.2777
4.2548
4.2677
4.2511
4.2817
4.3847
4.4418
4.4696
4.4932
4.4998
4.5151
4.5096
4.5278
4.5139
4.5020
4.4561
4.4067
4.3841
4.3638
4.3750
4.4366
4.5258
4.6565
4.6485
4.5836
4.5183
4.4583
4.3747
4.3509
4.2938
4.2823
4.2844
4.3135
4.3262
4.3255
4.2568
4.2011
4.1832
4.2278
4.2445
4.2409
4.2784
4.2917
4.3035
4.3015
4.3209
4.3204
4.3356
4.3287
4.3260
4.3483
4.3710
4.3798
4.3802
4.3805
4.5162
4.6906
5.0826
5.6588
6.0137
6.2436
6.5361
7.0790
7.6106
7.6410
7.4120
7.4535
7.2476
7.2596
7.1012
7.0986
6.9395
6.5633
5.8438
4.9434
4.6750
4.4320
4.3063
4.2096
4.0193
3.9698
4.0055
4.0218
4.0426
4.0688
4.0650
3.9793
3.9787
3.9766
3.9981
4.0405
4.0165
4.0290
4.0923
4.0897
4.0615
4.0258
4.0008
4.0274
4.0553
4.0646
4.0442
4.0477
3.9986
4.0354
4.0718
4.0563
4.0189
3.8631
3.8144
3.7736
3.8055
3.9730
4.0299
4.0148
3.8265
3.4675
3.3020
3.2474
3.2338
3.1986
3.1680
3.1289
3.0944
3.0523
3.0094
2.9510
2.9246
2.9057
2.8805
2.8545
2.8245
2.7690
2.7236
2.6833
2.6443
2.5969
2.5415
2.4684
2.4214
2.3699
2.3293
2.2513
2.1963
2.1285
2.0700
2.0209
1.9575
1.8658
1.6996
1.5120
1.4020
1.3087
1.2166
1.1441
1.0774
1.0226
0.9809
0.9448
0.8526
0.6915
0.4491
0.2842
0.2582
0.2570
0.2568
0.2609
0.2632
0.2581
0.2552
0.2539
0.2527
0.2578
0.2672
0.2701
0.2655
0.2658
0.2688
0.2761
0.2767
0.2738
0.2774
0.2801
0.2817
0.2803
0.2830
0.2828
0.2876
0.2952
0.2985
0.3016
0.3092
0.3130
0.3153
0.3182
0.3304
0.3471
0.3416
0.3476
0.3497
0.3453
0.3398
0.3448
0.3563
0.3511
0.3502
0.3481
0.3519
0.3573
0.3544
0.3512
0.3489
0.3499
0.3470
0.3533
0.3409
0.3556
0.3474
0.3435
0.3460
0.3519
0.3447
0.3395
0.3488
0.3473
0.3453
0.3433
0.3484
0.3526
0.3494
0.3607
0.3694
0.4126
0.4604
0.5004
0.5163
0.5328
0.5432
0.5506
0.5485
0.5605
0.5586
0.5622
0.5727
0.5804
0.5797
0.5666
0.5700
0.5696
0.5722
0.5715
0.5656
0.5572
0.5264
0.5156
0.5473
0.6286
0.7503
0.8715
0.8825
0.7507
0.5421
0.2869
0.1091
0.0423
0.0326
0.0343
0.0256
0.0231
0.0281
0.0298
0.0229
0.0283
0.0279
0.0270
0.0300
0.0245
0.0360
0.0280
0.0270
0.0232
0.0276
0.0270
0.0237
0.0197
0.0193
0.0172
0.0140
0.0093
0.0244
0.0226
0.0192
0.0145
0.0124
0.0167
0.0182
0.0111
0.0147
0.0081
0.0151
0.0130
0.0113
0.0131
0.0067
0.0028
0.0064
0.0069
0.0082
0.0075
0.0098
-0.0008
0.0037
0.0019
0.0060
0.0057
0.0033
0.0079
0.0122
0.0091
0.0067
-0.0038
0.0033
0.0013
0.0011
0.0034
0.0051
0.0009
-0.0001
-0.0005
0.0098
-0.0003
0.0067
0.0038
0.0106
0.0000
0.0126
0.0134
0.0090
0.0116
0.0083
0.0101
0.0152
0.0010
0.0068
0.0008
0.0053
0.0090
0.0087
0.0085
0.0054
0.0089
0.0077
0.0064
0.0046
0.0058
0.0025
0.0132
0.0088
0.0043
0.0052
0.0087
0.0122
0.0023
0.0066
0.0093
0.0042
0.0042
0.0138
0.0051
-0.0055
-0.0002
0.0048
0.0063
0.0076
0.0016
-0.0005
0.0086
0.0043
-0.0016
0.0100
0.0097
0.0042
0.0092
0.0051
0.0029
0.0044
0.0033
0.0073
0.0093
0.0077
0.0093
0.0021
0.0026
0.0093
0.0068
0.0039
0.0068
0.0041
0.0053
0.0037
0.0075
0.0016
0.0000
-0.0005
0.0073
0.0076
0.0049
0.0046
0.0087
0.0106
0.0072
0.0085
0.0036
0.0044
0.0043
0.0201
0.0076
0.0075
0.0134
0.0050
0.0071
0.0032
0.0055
0.0085
0.0046
0.0023
-0.0020
0.0027
0.0060
0.0066
0.0067
0.0014
0.0166
0.0067
0.0024
0.0072
0.0062
0.0081
0.0035
0.0077
0.0101
0.0045
0.0034
0.0144
0.0078
0.0065
0.0093
0.0181
0.0028
0.0050
0.0034
0.0063
0.0150
0.0035
0.0022
0.0079
0.0034
0.0110
0.0075
0.0058
0.0085
0.0152
0.0089
0.0060
0.0017
0.0041
0.0091
0.0072
-0.0109
0.0036
0.0063
0.0080
0.0037
0.0086
0.0097
0.0088
0.0016
0.0057
0.0059
0.0139
0.0061
0.0009
0.0059
0.0126
0.0117
0.0003
0.0060
0.0075
0.0073
0.0080
0.0154
0.0136
0.0121
0.0179
0.0150
0.0125
Instead of doing
f_filter = cconv(gf,f,length(f));
this does the trick:
f_filter = conv(gf,f);
f_filter = f_filter(sz/2+1:end-sz/2+1);
As suggested by #AnderBiguri you can use the option 'same' in your convolution fonction to preserve the original size of your array.
But if you apply a convolution with your normalized gaussian filter gf you will obtain a border effect.
To avoid the border effect you can apply the following tricks:
gf = exp(-x .^ 2 / (2 * sigma ^ 2)); %do not normalize gf now
f_filter = conv(f,gf,'same')./conv(ones(length(f),1),gf,'same') %normalization taking into account the lenght of the convolution
For example I've just transformed f into f = f+3
If we do not take into account the border effect we will obtain:
Check out following toy example:
m = 3;
n = 3;
Y = rand(m,n,2);
for example gives me
y(:,:,1) =
0.8314 0.3993 0.6569
0.8034 0.5269 0.6280
0.0605 0.4168 0.2920
y(:,:,2) =
0.4317 0.1672 0.1981
0.0155 0.1062 0.4897
0.9841 0.3724 0.3395
now when I reshape it using
reshape(Y,m*n,2)
it disturbs the order and gives me,
0.8314 0.4317
0.8034 0.0155
0.0605 0.9841
0.3993 0.1672
0.5269 0.1062
0.4168 0.3724
0.6569 0.1981
0.6280 0.4897
0.2920 0.3395
because here 2nd row should be
0.3993 0.1672
this can be crosschecked before reshaping by
Y(1,1,:)
Y(1,2,:)
etc.
The order changes.
PS : I have huge data to be fed in Neural network and this affects the way my weights are being multiplied.
Add in permute there and then reshape, like so -
reshape(permute(y,[2,1,3]),[],size(y,3))
Sample run -
>> y
y(:,:,1) =
0.8314 0.3993 0.6569
0.8034 0.5269 0.628
0.0605 0.4168 0.292
y(:,:,2) =
0.4317 0.1672 0.1981
0.0155 0.1062 0.4897
0.9841 0.3724 0.3395
>> reshape(permute(y,[2,1,3]),[],size(y,3))
ans =
0.8314 0.4317
0.3993 0.1672
0.6569 0.1981
0.8034 0.0155
0.5269 0.1062
0.628 0.4897
0.0605 0.9841
0.4168 0.3724
0.292 0.3395
I want to solve the following equation for X. All parameters in my equation are matrices:
( [A]' * [X] )+( [X] * [A] ) = -I
I =
0 0 0 0
0 0 0 0
0 0 6.7955 -2.8529
0 0 -2.8529 3.9426
and
[A] =
-0.0038 -0.0011 -0.0012 -0.0012
-0.0011 -0.0049 -0.0012 -0.0023
1.0000 0 0 0
0 1.0000 0 0
You can use sylvester:
>> sylvester(A', A, -I)
ans =
1.0e+06 *
2.2772 -1.4202 0.0071 -0.0045
-1.4202 0.9749 -0.0043 0.0032
0.0071 -0.0043 0.0011 -0.0005
-0.0045 0.0032 -0.0005 0.0005
This might be a simple task, but as im new to matlab, i have not been able to figure it out.
I have a matrix with two relevant columns, first column consists of hour-by-hour measurements of electricity consumption over the span of a month(so around 740 values). The second column consists of datenum values corresponding to each measurement.
The electricity-measurements have clear peaks, and I want to sum up each peak, from a lower boundary of 150, up to the peak and "down" to 150 again. Each month there are roughly 10-15 peaks, and i want to sum up each peak and store it in a vector together with its corresponding time so i can identify where the peaks occur,and how big they are. Im able to find the consumption values, but have trouble getting the corresponding times from the second column.
Does anyone have a solution to how I can do this?
Sorry for the confusing problem description.
Many Thanks
Edit:
Here is a sample from the data:
0.1250 2.0130 0.0080 0.0030 0.0150 0 0
0.1299 2.0130 0.0080 0.0030 0.0160 0 0
0.1368 2.0130 0.0080 0.0030 0.0170 0 0
0.1333 2.0130 0.0080 0.0030 0.0180 0 0
0.1343 2.0130 0.0080 0.0030 0.0190 0 0
0.1349 2.0130 0.0080 0.0030 0.0200 0 0
0.1250 2.0130 0.0080 0.0030 0.0210 0 0
0.1150 2.0130 0.0080 0.0030 0.0220 0 0
0.1150 2.0130 0.0080 0.0030 0.0230 0 0
0.1000 2.0130 0.0080 0.0040 0 0 0
0.1000 2.0130 0.0080 0.0040 0.0010 0 0
0.0950 2.0130 0.0080 0.0040 0.0020 0 0
0.0900 2.0130 0.0080 0.0040 0.0030 0 0
0.0850 2.0130 0.0080 0.0040 0.0040 0 0
0.0850 2.0130 0.0080 0.0040 0.0050 0 0
0.0848 2.0130 0.0080 0.0040 0.0060 0 0
0.0893 2.0130 0.0080 0.0040 0.0070 0 0
0.0883 2.0130 0.0080 0.0040 0.0080 0 0
0.0817 2.0130 0.0080 0.0040 0.0090 0 0
0.0836 2.0130 0.0080 0.0040 0.0100 0 0
0.0831 2.0130 0.0080 0.0040 0.0110 0 0
0.1017 2.0130 0.0080 0.0040 0.0120 0 0
0.1021 2.0130 0.0080 0.0040 0.0130 0 0
0.0949 2.0130 0.0080 0.0040 0.0140 0 0
All values are 1.0e+03 *
The first values are the consumption values and the rest are the datevec values for each consumption value. I need to be able to pick out the values from the first column that are above 150 and store them with their corresponding datevec values.
Hopes this helps. Im completely new to this so sorry for my 'noobish' questioning!
EDIT:
Im very new to matlab so haven't gotten it to work.
Gonna try a more "easy" approach.
The data i have is 740x1
sample of the data:
94.9997
89.9986
104.9981
139.8430
158.6546
161.6176
169.8047
178.4623
192.4402
207.0930
199.7369
190.2221
181.6872
173.1552
159.8161
149.9443
134.9956
129.9899
114.9989
99.9990
89.9990
89.9991
84.9991
79.9991
79.9989
84.9901
94.9928
149.9995
174.9977
174.7706
179.7816
179.8007
203.4999
208.6901
209.1134
199.3191
183.5979
164.4079
154.8898
140.0000
129.9494
124.9923
124.9987
104.9993
109.9994
94.9995
94.9995
84.9995
84.9995
84.9953
85.0000
84.8889
83.7396
I need a program that goes through the data and picks out the numbers higher than 150 and groups them. I realised that i don't really need the time, i only need to separate the peaks from each other.
I need it to run something like this:
%for loop that runs through the data
%picks out the first set of values over 150
%stores them in a matrix: column 1
%picks out the next set of values over 150
%stores them in the same matrix: column 2
%picks out the next set of values over 150
%stores them in the matrix: column 3
Appreciate all of your help, and I'm sure i could use the previous suggestions if i had a better understanding of matlab and programming in general.
Sorry for all the trouble!
You can access the right rows with high consumption with logical indexing. Let's say the name of your matrix is data.
But before, I would improve the structure of the data, e.g. with structs:
% structure data and identify high consumption measurements
measurements.consumption = data(:,1);
measurements.datevec = data(:,2:end);
measurements.ixHigh = measurements.consumption>150;
% get measurements with high consumption
peakMeasurements.comsumption = measurements.consumption(measurements.ixHigh);
peakMeasurements.datevecs = measurements.datevecs(measurements.ixHigh,:);
If you're lucky and you own Matlab 2013b or newer, you can use tables to store your data more human readable.
Ok.
This is not very matlabish... but it could help you get started:
sum = 0; %keeps track of the sum in the interval
max = 0; %keeps track of the peak
maxi = 0; %keeps track of the peak index
aux1 = 1; %aux variable
minv = 100;
for i = 1:length(A)
if i==1 && A(i,1)<minv
elseif A(i,1) >= minv
sum = sum + A(i,1);
if A(i,1) > max
max = A(i,1);
maxi = i;
end
elseif A(i,1) < minv && A(i-1,1) >= minv
B(aux1,1) = sum;
B(aux1,2:7) = A(maxi,2:7);
sum = 0;
max = 0;
maxi = 0;
aux1 = aux1 + 1;
elseif A(i,1) < minv && A(i-1,1) < minv
end
end
Running that code with your sample data gives:
1349.2 2013 8 3 17 0 0
203.8 2013 8 4 13 0 0
The first column gives the sum from the first 100 to the last 100 (I used 100 because none of the values of your data was bigger than 150, you can change this value by changing minv) and the rest of the columns corresponds to the date and hour of when the peak in that particular interval of time occured, if necessary you can add a new column to add the actual peak value too.
Using the Matlab capabilities for logical indexing (as mentioned by JaBe) this solution should be faster than looping over all elements of A(:,:)
% Generate Demo data
A=[]
A(1:100,1)=20+ (1:100); % Time values
A(1:100,2)=rand(100,1) % scatter
A(20:25,2) = 155 % first peak
A(44:79,2) = 157 % second peak
% Add column with index
Aix=[(1:size(A,1))', A]; % [Index, time, Value]
% Just the peak values
B=Aix(Aix(:,3)>150,:)
% Collection of Peak Values
Peaks = B(1,:)
i_start=B(1,1)
for i=2:size(B,1)
if B(i,1)==B(i-1,1)+1 % Datapoint belongs to previous peak
Peaks(end,3) = Peaks(end,3) + B(i,3); % Sum Value to Peak Result
else % Generate Dataset for new Peak
Peaks = [Peaks ; B(i,:)]; % Add new Dataset
end
end;
disp (' Start Index | Start time | Sum Value')
disp ( Peaks)
Will give your the following result
Start Index | Start time | Sum Value
20 40 930
44 64 5652
Let the name of your vector be data. This will give you the sums of all the peaks:
sumvec = [];
while(1)
beginindex = find(data>150,1);
if length(beginindex)==0
break;
end
data = data(beginindex:end);
endindex = find(data<150,1);
if length(beginindex)==0
break;
end
sumvec = [sumvec sum(data(beginindex:endindex))];
data = data(endindex:end);
end
I think some boundary conditions will break, but otherwise, is this what you want?
I have a txt file with data, so I used the following function
M = dlmread('data.txt', '\t');
But My data is getting converted to exp(-3) how do I avoid that?
Here how the data look like:
M =
1.0e+03 *
0 0.0080 0.3500 0.1500 4.6990 0.0145 0.0740 0
0 0.0080 0.4000 0.1700 4.7460 0.0120 0.0710 0
0 0.0080 0.4000 0.1750 4.3850 0.0120 0.0720 0
0 0.0060 0.2500 0.0720 3.1580 0.0195 0.0750 0
0 0.0080 0.3040 0.1500 3.8920 0.0125 0.0720 0
0 0.0080 0.3500 0.1450 4.4400 0.0140 0.0750 0
0 0.0060 0.2500 0.1050 3.8970 0.0185 0.0750 0
0 0.0060 0.1630 0.1330 3.4100 0.0158 0.0780 0.0010
0 0.0080 0.2600 0.1100 4.0600 0.0190 0.0770 0
As H Muster says, this is a display issue.
A better way (in my opinion) of displaying your data is via num2str.
If you run
num2str(M)
you will see
ans =
0 0.008 0.35 0.15 4.699 0.0145 0.074 0
0 0.008 0.4 0.17 4.746 0.012 0.071 0
0 0.008 0.4 0.175 4.385 0.012 0.072 0
0 0.006 0.25 0.072 3.158 0.0195 0.075 0
0 0.008 0.304 0.15 3.892 0.0125 0.072 0
0 0.008 0.35 0.145 4.44 0.014 0.075 0
0 0.006 0.25 0.105 3.897 0.0185 0.075 0
0 0.006 0.163 0.133 3.41 0.0158 0.078 0.001
0 0.008 0.26 0.11 4.06 0.019 0.077 0
which is probably what you were expecting in the first place.
If you want more precision, pass a format string to num2str.
For example:
num2str(M,'%8g')