how to order the array according to the condition of linear ordering?

1 次查看(过去 30 天)
I am making a program based upon the module placement according to the linear condition consider the example:
module=[2 3 5 4 1 6] from the below given code one can give the module input which is the above one
enter the number of terminating points for the module enter the number of new points for the module enter the number of continuing points for each module
now the gain for each module is calculated as gain = terminating points - new points
note that:
the above loop will run till the max length of the module
now the condition are find the max gain 1)if in the array of the gain two module have same gain and both are having maximum value
then check the maximum no of terminating points for each of the module having maximum gain 2)if still both have the tie then selected the module having maximum number of continuing points 3)if still there is a tie then select the module which has the minimum number of points i.e: min(terminating points,continuing points,new points); else place it in the same order in the new module now remove the module from the previous array and run the program again until all the module in the array are arrange
%%ALGOORITHM FOR LINEAR CLUSTER GROWTH %%
%number of module
clc;
clear all;
tn = [];
nn = [];
cn = [];
G = [];
module=input('enter the module= ');
s=length(module);
for i=1:s;
disp('+----------------------------------------------------+');
disp('module no = ');disp(s(i));
terminating_net = input('enter the number of terminating net for this module= ');
tn(1,i) = terminating_net;
new_net = input('enter the number of new net for this module= ');
nn(1,i) = new_net;
continuting_net = input('enter the number of continuing net for this module= ');
cn(1,i) = continuting_net;
gain = terminating_net - new_net;
G(1,i) = gain;
s=s+1;
disp('TN -----------------------------------------------');disp(tn);
disp('NN -----------------------------------------------');disp(nn);
disp('CN -----------------------------------------------');disp(cn);
disp('G -----------------------------------------------');disp(G);
end
disp('_________________________________________________________');
gmax=zeros(1,s);
gmax=max(G);
disp('Max Gain');disp(gmax);
disp('_________________________________________________________');
%%conditon
help me plz

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polynomials 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by