Code matlab to c
karkar2011
Messages postés
7
Date d'inscription
Statut
Membre
Dernière intervention
-
damlegone32 Messages postés 74 Date d'inscription Statut Membre Dernière intervention -
damlegone32 Messages postés 74 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai un programme en matlab, je vais le converti en c ou c++;Est ce que vous pouvez m'aidez svp c'esttrés urgent.
voila le fichier matlab:
clear;
load capacity_phy.dat
C=capacity_phy;
net_size=size(C);
N=net_size(1);
max_th=zeros(N,N);
tree=zeros(N,N);
for i=1:N
visited=[];
not_visited=zeros(N,1);
for j=1:N
not_visited(j)=j;
tree(i,j)=i;%Au debut, tous les sommets sont accessibles a partir de i.
end
%Debut de Dijkstra pour le Maximum Throughput Path MTP avec i comme sommet.
visited=[visited;i];
not_visited(i)=0;
max_th(i,:)=C(i,:);%Au debut, le MTP entre i et j est le chemin direct.
not_visited_cap=max_th(i,:);
while (any(not_visited))%Repeter tant que not_visited n'est pas vide.
[m,S]=max(not_visited_cap);%S contient les sommets qui realisent le MTP.
s=S(1);% S'il y a plus d'un sommet, on prend le premier.
visited=[visited;s];
not_visited(s)=0;
not_visited_cap(s)=0;
for t=1:N
if not_visited(t)~=0
if C(s,t)~=0 %Pour tous les sommets t relies directement a s
if max_th(i,s)<C(s,t)
x=max_th(i,s);
else
x=C(s,t);
end
if max_th(i,t)<x
max_th(i,t)=x;
not_visited_cap(t)=x;
tree(i,t)=s;
end
end
end
end
end
end
movefile('capacity_log.dat','capacity_log1.dat')
fid=fopen('capacity_log.dat','w');
for i=1:N
for j=1:N
fprintf(fid,'%d \t',max_th(i,j));
end
fprintf(fid,'\n');
end
fclose(fid);
movefile('mtp_tree.dat','mtp_tree1.dat')
fid=fopen('mtp_tree.dat','w');
for i=1:N
for j=1:N
fprintf(fid,'%d \t',tree(i,j));
end
fprintf(fid,'\n');
end
fclose(fid);
j'ai un programme en matlab, je vais le converti en c ou c++;Est ce que vous pouvez m'aidez svp c'esttrés urgent.
voila le fichier matlab:
clear;
load capacity_phy.dat
C=capacity_phy;
net_size=size(C);
N=net_size(1);
max_th=zeros(N,N);
tree=zeros(N,N);
for i=1:N
visited=[];
not_visited=zeros(N,1);
for j=1:N
not_visited(j)=j;
tree(i,j)=i;%Au debut, tous les sommets sont accessibles a partir de i.
end
%Debut de Dijkstra pour le Maximum Throughput Path MTP avec i comme sommet.
visited=[visited;i];
not_visited(i)=0;
max_th(i,:)=C(i,:);%Au debut, le MTP entre i et j est le chemin direct.
not_visited_cap=max_th(i,:);
while (any(not_visited))%Repeter tant que not_visited n'est pas vide.
[m,S]=max(not_visited_cap);%S contient les sommets qui realisent le MTP.
s=S(1);% S'il y a plus d'un sommet, on prend le premier.
visited=[visited;s];
not_visited(s)=0;
not_visited_cap(s)=0;
for t=1:N
if not_visited(t)~=0
if C(s,t)~=0 %Pour tous les sommets t relies directement a s
if max_th(i,s)<C(s,t)
x=max_th(i,s);
else
x=C(s,t);
end
if max_th(i,t)<x
max_th(i,t)=x;
not_visited_cap(t)=x;
tree(i,t)=s;
end
end
end
end
end
end
movefile('capacity_log.dat','capacity_log1.dat')
fid=fopen('capacity_log.dat','w');
for i=1:N
for j=1:N
fprintf(fid,'%d \t',max_th(i,j));
end
fprintf(fid,'\n');
end
fclose(fid);
movefile('mtp_tree.dat','mtp_tree1.dat')
fid=fopen('mtp_tree.dat','w');
for i=1:N
for j=1:N
fprintf(fid,'%d \t',tree(i,j));
end
fprintf(fid,'\n');
end
fclose(fid);
A voir également:
- Code matlab to c
- Code ascii - Guide
- Code puk bloqué - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code activation windows 10 - Guide
- Qwerty to azerty - Guide