I can not return real values
Show older comments
Hi I have the result of recursive function is saved in txt file , Below are the results of calling recursive fun. that each call divide the vector into two vectors. the problem is when the function divide the vector , give the new vectors the indices of values in original vectors not the same values.So, I lose the real numbers
for ex. this txtfile
*3 4 5 8 9 10
1 2 3
4 5 6
3
1 2
1 2
3 *
I want code by which can return these vectors
*cluster(1)=[3 4 5 8 9 10]
cluster(2)=[3 4 5]
cluster(3)=[8 9 10]
cluster(4)=[5]
cluster(5)=[3 4]
cluster(6)=[8 9]
cluster(7)=[10]*
thanks in advance
2 Comments
Image Analyst
on 14 Sep 2012
Which one of the sets of values are "the results of calling recursive fun"??? All I see are the input, and the desired output, not the results of your recursive function.
huda nawaf
on 14 Sep 2012
Answers (2)
Jürgen
on 14 Sep 2012
0 votes
I am not sure if I get it , is not so clearly explained but I would work with the length of the OriginalVector of size(OriginalVector,2) and divide it by two ( you will need to use ceil or fix if you have an odd length of course
so in pseudo code
Length= length(V)
HalfLenght=ceil(Length/2)
V1=V(1:HalfLength) V1=V(HalfLength+1:Length)
repeat this until length result is one
or am I mistaken ?
5 Comments
Image Analyst
on 14 Sep 2012
I'm pretty sure this is related to, and follow up on, his several other, complicated recursion questions. Look up his profile if you're interested in helping further, or await a response here.
huda nawaf
on 14 Sep 2012
huda nawaf
on 14 Sep 2012
Edited: huda nawaf
on 14 Sep 2012
huda nawaf
on 14 Sep 2012
Jürgen
on 15 Sep 2012
Maybe it is because it is the weekend that I am slow but to be sure I'll try to check if I understand it: in your txt file you have a list of numbers that you read into matlab en put in a vector:x=[3 4 5 8 9 10]; then you divide the vector in parts being: [3 4 5] & [8 9 10]&[5]&[3 4]&[8 9]&10
what do you want to do next? write to the txt?
I think this code does what you want or no what I think that you want :-) Of course much nicer if you make a function of it X=[3 4 5 8 9 10];
L=length(X);
NewL=ceil(L/2);
Xnew1=X(1:NewL);
Xnew2=X(NewL+1:L);
X=Xnew1;
L=length(X);
NewL=ceil(L/2);
Xnew1=X(1:NewL);
Xnew1=X(NewL+1:L);
X=Xnew2;
L=length(X);
NewL=ceil(L/2);
Xnew1=X(1:NewL);
Xnew1=X(NewL+1:L);
7 Comments
huda nawaf
on 15 Sep 2012
Jürgen
on 15 Sep 2012
I am very sorry, I would like to help you but I don't understand your explaination, and your English is not really helping
"What if the function returned different indices"?? what do you mean?maybe post that function?
"L1 1 2 %%%%this is first vector." Do you mean L1=[1 2]?
"L3 1 this is first vector of L1" How can one elment be the first vector of L1? " this is agian unclear
So , the function returen the indices by which I can recover the original values of vector"
please give us some code and the input vector
or maybe somebodyelse can help you Maybe a final comment: I see that you talk about a function that returns indices adn that you want to have values. I suppose you know that if i is the index X(i) gives the values.
huda nawaf
on 16 Sep 2012
Jürgen
on 16 Sep 2012
hello Huda,
I am happy that you solved ypur problem. For your new question the problem for me stays the same: I do not understand the problem based on your explantion:"but if i used large size of data, it is dificult to know the clusters, so i need code to find clusters" this is totally unclear to me: post example input, post your code. Input=[ something ]; function Output= NameFucntion(Input) code and show Output
regardsJ
huda nawaf
on 16 Sep 2012
huda nawaf
on 16 Sep 2012
huda nawaf
on 19 Sep 2012
Categories
Find more on Linear Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!