To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
I have recurrent function , this function has two outputs and each output will be input next in time. I built divide function, this function divide the input into two parts , and each one of the two parts will be input to same function and get two outputs and so on
let divide whatever function
I need help to do that.
No products are associated with this question.
Here is some recursive code:
% Demo to rotate an ellipse over an image. % By ImageAnalyst function [aboveMedian belowMedian] = test2(v) % Initialize aboveMedian = v; belowMedian = v; % Stopping condition. if length(v) <= 1 return; end medianValue = median(v); indexesAboveMedianVaue = v > medianValue; aboveMedian = v(indexesAboveMedianVaue); belowMedian = v(~indexesAboveMedianVaue); % Stopping conditions. if length(aboveMedian) <= 1 && ... length(belowMedian) <= 1 return; end if length(belowMedian) == length(v) return; end fprintf('For v = '); fprintf('%f, ', v); fprintf('\n Median = %f', medianValue); fprintf('\n Values above median = '); fprintf('%.1f, ', aboveMedian); fprintf('\n Values at or below median = '); fprintf('%.1f, ', belowMedian); fprintf('\n'); % Now recurse in with the two outputs test2(aboveMedian); test2(belowMedian);
It sort of does what you were trying to do with the median. Try it with this code:
a=[2 3 4 56 7 85 3 5 7 7]; [am bm] = test2(a)
But it will quit early because I'm not really sure when you want to stop. What are your stopping conditions when you won't recurse in anymore? I don't have the right stopping conditions in there. Anyway, it's a start and I'll leave it up to you to finish. Good luck.