Verfasst am: 09.05.2012, 21:52
Titel: "Unnütze" Werte aus dem Plot rausschmeissen
Hallo, ich hab hier ein Quellcode und muss in dem Plot nur die CN-Werte darstellen, welche kleiner sind als die vorhergehenden CN Werte,
Wie muss ich dazu den plot Befehl verändern?
Hier ist der Quellcode:
Code:
function[Lropt, CNopt]=lfstfs(Lfs,r,nTotalIterations,launchrandom) % % Find submatrix rxt, 1<=r<=s, where [s,t]=size(Lfs) % by tabu search algorithm from the matrix Lfs % Lfs - input matrix lead field matrix, sxt % r - number of sources % launchrandom - is to initialize random generator % nTotalIterations - toral number of iterations % % example: % Lfs=rand([3146 13]); % [Lr, CN]=lfsts(Lfs, 16, 999, 123); % Lfs=repmat(Lr,[20,1]); % [Lr, CN]=lfsts(Lfs, 16, 999, 123);
% s=3146; % number of sensors % t=13; % number of sources % r=24; % number of selected sensors, between 13 and 100
% to keep previous tests
TabuList=zeros([r nTotalIterations]);
CNlist=zeros([nTotalIterations 1]);
% e is the number of rows to exchange, at the beginning =r/2 % fractionToChange=1.0; % ( 0 < fractionToChange <=1) % % when e=r - global search (all rows are changed) % % when e=1 - local search (only 1 row is changed) % e=max(1,round(fractionToChange*r));
e=r;
% to keep old indices in Lr
iRowsinLrold=zeros([e 1]);
% For the very first run, the simplest case % iRowsInLr - indices of rows in Lr taken from Lfs % at the beginning 1:r just to initialize, might be any set, % e.g. iRowsInLr - previous best solution
%iRowsInLr=1:r;
iRowsInLr=round(1+(s-1)*rand([e 1]));
Lr=Lfs([iRowsInLr],:);
CN=cond(Lr);
CNold=9999999999;
%*****************************************
%---- the main loop of the algorithm ****
%*****************************************
iteration=0;
iterationWithChange=0;
while1 if CN < 1.1 || iteration >= nTotalIterations; % stop algorithm break end
% ----- next iteration ------------------------
% the indices of rows to change in the Lr
iChangeInLr=round(1+(r-1)*rand([e 1]));
% keep indices in rows which will be changed
iRowsinLrold=iRowsInLr([iChangeInLr]);
% keep prevous CN
CNold=CN;
% indices of rows in Lfs which have not been yet tried (clean rows)
ntry=2;
iNotVisitedRowsInLfs=find(usedrows <= ntry); % ntry times try each row % the total number of "clean" rows in Lfs, see below
nNotVisitedRowsInLfs=length(iNotVisitedRowsInLfs);
if nNotVisitedRowsInLfs < e
disp('all rows in Lfs have been tried') disp([' CN = ' num2str(CN)...
' e = ' num2str(e)...
' iteration,iterationWithChange = ' num2str(iteration)...
',' num2str(iterationWithChange)]);
% change (decrease by factor 2) the number of rows in Lr to replace if(e > 100)
%e=round(3/4*e);
e=e-1;
else if e==1 break else
e=e-1;
end end % nullify usedrows
usedrows=zeros([s 1]);
continue end
%the indices of rows to take from Lfs, clean = counted for the "clean" rows
iTakeFromLfsClean=round(1+(nNotVisitedRowsInLfs-1)*rand([e 1]));
% the indices of rows in Lfs counted with all rows
iTakeFromLfs=iNotVisitedRowsInLfs([iTakeFromLfsClean]);
% replace e indices in iRowsInLr
iRowsInLr([iChangeInLr])=iTakeFromLfs;
% update Lr
Lr([iChangeInLr],:)=Lfs([iTakeFromLfs],:);
Verfasst am: 13.05.2012, 02:41
Titel: Re: "Unnütze" Werte aus dem Plot rausschmeissen
Hallo bmtil,
Wir können Dein Programm wegen der fehlenden Inputs nicht laufen lassen. Es ist auch recht umfangreich und es ist zeitraubend herauszufinden, wie die "CN-Werte" erstellt werden und was Du erreichen möchtest.
"Das klappt gerade alles nicht so richtig wie ich mir vorstelle" ist keine hilfreiche Beschreibung des Problems.
Ich würde empfehlen den relevanten Teil des Programms zu posten, vielleicht lassen sich die "CN-Werte" ja testweise per RAND erzeugen, ohne dass die eigentliche Frage-Stellung darunter leidet. Und dann beschreibe noch exakt, welches Problem in der bisherigen Version des Programm auftritt.
Hallo, ich hab das Problem bereits loesen koennen.
Das Thema besitzt keine Relevanz mehr.
Grueße.
Einstellungen und Berechtigungen
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.