Effacer les filtres
Effacer les filtres

Some variables not being shown in workspace

1 vue (au cours des 30 derniers jours)
Rakesh Jain
Rakesh Jain le 18 Août 2017
Commenté : Rakesh Jain le 18 Août 2017
I am implementing an optimisation heuristic algorithm in matlab. When I run it, some of the variables are not coming up in workspace. When I run that variable (say xyz) from Command window, it says undefined variable xyz. Though I can see that variable xyz is defined in the program. Program was running well until day before yesterday but suddenly why are such problems coming. Why is this happening? The program is attached
clc;
clear;
close all;
INITIAL PARAMETERE VALUE
N=5;TS=100;LB=[1 0.1 0.1 0.1 0.1];UB=[50 30 25 0.99 0.99];ITER=2000;
Costfunction= @pidisefrac2;
INITIAL POPULATION
Individual.Position=zeros(1,N);
Individual.Cost=zeros(1,1);
Pop=repmat(Individual,TS,1);
for i=1:TS
for j=1:5
Pop(i).Position(j)=unifrnd(LB(j),UB(j),1,1);
end
Pop(i).Cost=Costfunction(Pop(i).Position);
end
EVALOTUNARY SECTION
for i=1:ITER
for j=1:N
sum1=0;
sum2=0;
for k=1:TS
sum1=sum1+Pop(k).Position(j)*(1/Pop(k).Cost);
sum2=sum2+1/Pop(k).Cost;
end
Center(j)=sum1/sum2;
end
for j = 1:5
c=(0.5*(UB-LB))/(1+ITER/10);
end
for k=1:TS-1
for j= 1:5
Pop(k).Position(j)=Center(j)+c(j)*normrnd(0,1,1,1);
end
for j=1:N
if Pop(k).Position(j)<LB
Pop(k).Position(j)=LB;
end
if Pop(k).Position(j)>UB
Pop(k).Position(j)=UB;
end
end
Pop(k).Cost=Costfunction(Pop(k).Position);
end
Pop(end).Position=Center;
Pop(end).Cost=Costfunction(Center);
Costs=[Pop.Cost];
[BestCost(i) index] = min(Costs)
BestmPosn (i,:) = Pop(index).Position;
end
RESULT
Costs=[Pop.Cost];
BestCost = min(Costs)
pidisefrac2.m
function ise = pidisefrac2(x)
sys = fotf([0.08 1.88 0],[2 1 0],[1.8],[0]);
pidi = fotf([1 0],[x(4) 1],[x(3) x(1) x(2)],[x(4)+x(5) x(4) 0]);
sysnew = sys*pidi;
final = feedback(sysnew,1);
%finalWithoutPID = tf([0.01125],[0.0005 0.01175 0.01125]);
[y t]=step(final,0:0.001:10);
ac =stepinfo(y,t,1);
% step(final)
for i = 1:101
error(i) =1 - y(i);
end
error1=error*error';
ise=abs(sum(error1));
  7 commentaires
Stephen23
Stephen23 le 18 Août 2017
Modifié(e) : Stephen23 le 18 Août 2017
I do not have the FOTF toolbox which you seem to be using, but when I replace the cost function with:
Costfunction = @(varargin)1;
then the script runs without error, and returns:
BestCost =
1
>> BestmPosn
BestmPosn =
25.587 16.222 13.446 0.50843 0.51146
25.423 16.34 13.621 0.50816 0.51123
25.631 16.285 13.56 0.50519 0.51467
25.42 16.233 13.448 0.50802 0.51374
25.414 16.294 13.555 0.50112 0.51198
25.436 16.287 13.507 0.50512 0.51118
etc.
Rakesh Jain
Rakesh Jain le 18 Août 2017
The mistake was mine. I had taken time to be 0:0.001:10. Thus the processing time increased and thus it was taking longer time. I was using ctrl+C earlier to break the program. Another question : if I uncomment the sixth last line step(final), the graph of the response which shows up is for 0.1 second. What if i want to check the response till 1 second or say 5 seconds

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by