Separating elements in Length vectors
1 次查看(过去 30 天)
显示 更早的评论
Suppose I have the following data set:
Length =
1.02219692622952
8.29383522727246
17.3975329545455
26.5394026041666
37.4131448863634
48.709668181819
51.4079249999999
61.0677
67.3565390625
76.1625590909094
85.4651375000007
94.6553875000006
105.547397159091
116.990150000001
119.621383914209
129.406797916667
133.8319
141.022715625
150.280673295453
159.456462499999
170.332771874999
181.707094886364
184.246947727274
193.971341666667
204.952635795454
214.060199999998
223.163925000002
233.997125000002
245.374622960725
247.969915909091
197.672519594595
257.617404411765
260.998768555373
268.448049999999
277.622496875
286.750634374999
297.561936363639
308.926818749999
311.588342613638
321.184121875001
328.941806034484
347.096843750003
356.222274999998
367.040681250001
378.45856363637
381.169198863638
390.490676136364
337.968181250005
I want to count how many times the data runs for every
61.0677
129.406797916667
193.971341666667
257.617404411765
321.184121875001
390.490676136364
I was wondering how this can be done.
10 个评论
Walter Roberson
2013-2-25
Are you trying to divide the list up into groups of 8 elements? Or are you trying to divide the list up by grouping spans of about 65? (Not 60 or else 61.067 would have to be in the second group; has to be at least 65 for 129.406797916667 to stay in the second group instead of moving to the third) ?
采纳的回答
Azzi Abdelmalek
2013-2-25
编辑:Azzi Abdelmalek
2013-2-25
v=min(x):60:max(x); % x is your array
id=0;
clear out
for k=2:numel(v)
[~,idx]=min(abs(x-v(k)));
id(k)=idx;
out{k-1}=x(id(k-1)+1:id(k))
end
15 个评论
Azzi Abdelmalek
2013-2-28
编辑:Azzi Abdelmalek
2013-2-28
a={3.1364 0.3734 NaN 3.2622 3.0374 nan 2.9695}
idx=cellfun(@isnan,a)
a(idx)={0}
更多回答(3 个)
Morteza
2013-2-25
编辑:Azzi Abdelmalek
2013-2-25
clc,clear
format long
Length = [
1.02219692622952
8.29383522727246
17.3975329545455
26.5394026041666
37.4131448863634
48.709668181819
51.4079249999999
61.0677
67.3565390625
76.1625590909094
85.4651375000007
94.6553875000006
105.547397159091
116.990150000001
119.621383914209
129.406797916667
133.8319
141.022715625
150.280673295453
159.456462499999
170.332771874999
181.707094886364
184.246947727274
193.971341666667
204.952635795454
214.060199999998
223.163925000002
233.997125000002
245.374622960725
247.969915909091
197.672519594595
257.617404411765
260.998768555373
268.448049999999
277.622496875
286.750634374999
297.561936363639
308.926818749999
311.588342613638
321.184121875001
328.941806034484
347.096843750003
356.222274999998
367.040681250001
378.45856363637
381.169198863638
390.490676136364
337.968181250005];
for i = 1:length(Length)
STR{i,1} = sprintf('%4.12f',Length(i));
end
S0 = input('Enter number : ');
S1 = sprintf('%4.12f',S0);
count = 0;
for i = 1:length(Length)
if strcmp(S1,STR{i,1}) == 1
count = count+1;
end
end
count
0 个评论
Morteza
2013-2-25
编辑:Morteza
2013-2-25
what is your MATLAB version?
I write this in MATLAB 2012b and it is work to find out each value, how many times repeated.
you have diffrent floating point data, without converting them into the string you will not be able to find the exact value.
Moreover your data does not have any specific character in each bunch, therefore finding the number of bunches become impossible, except by increasing rate or number of counter for each bunch may be it is possible...
As I see for each 60 period you have one bunch, may be you can use of this parameter....
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!