Hello Everyone, I am new in MATLAB and I want to get result of this code(MATLAB2021a), its run correctly but doesn't show the result. Anyone can help me?? thanks in advance
    4 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    ARAM KHURSHEED
 am 11 Jan. 2022
  
    
    
    
    
    Kommentiert: ARAM KHURSHEED
 am 13 Jan. 2022
            c=[ ];
global d;
c(1,d)= ran(10,21);
function x = ran(min,max)
x= fix ((max-min).*rand(1,1) + min)+1;
end
It should give me number but doesn't show any numbers.
Many Thanks for your help
4 Kommentare
  Cris LaPierre
    
      
 am 11 Jan. 2022
				OP's comments moved here.
i want to get this table

the attachment code is to create this table, the result should be save in NewNetwok but this not occure this is my problem .
Best Regards 
%RATs%%%%%%%%%%%
global UMTS;
global LTE;
global WIFI;
global WIMAX;
global FiveG;
global CostperByte;
global Security;
global DataRate;
global PacketDelay;
global PacketJitter;
global PacketLoss;
%%%%%%%%%%%%%%%%
NetworksNames=[];
NetworksList=["LTE";"WIMAX";"UMTS";"WIFI";"FiveG"];
N= size (NetworksList);
N=N(2);
UMTSToString=1;
LTEToString=1;
WIFIToString=1;
WIMAXToString=1;
FiveGToString=1;
for i=1:N 
NewNetwork=[]; 
switch NetworksList(i)
    case 'WIFI'
       % %{
        NewNetwork(1,CostperByte)=5 ;
        if mod(WIFIToString,2) == 1
        NewNetwork(1,CostperByte)=10 ;         
        end
        NewNetwork(1,Security)= 50;
        NewNetwork(1,DataRate)= ran(1,11);
        NewNetwork(1,PacketDelay)= ran(100,150);
        NewNetwork(1,PacketJitter)= ran(10,20);
        NewNetwork(1,PacketLoss)= ran(20,80);
        NetworksNames=[NetworksNames,"Wi-Fi"+" "+int2str(WIFIToString)];
        WIFIToString=WIFIToString+1;
       % %}
       %{
        NewNetwork(1,CostperByte)=ran(0,1) ;
        NewNetwork(1,Security)= ran(0,90) ;
        NewNetwork(1,DataRate)= ran(0.1,5);
        NewNetwork(1,PacketDelay)= ran(50,200);
        NewNetwork(1,PacketJitter)= ran(0,8);
        NewNetwork(1,PacketLoss)= ran(0,4);
        NetworksNames=[NetworksNames,"Wi-Fi"+" "+int2str(WIFIToString)];
        WIFIToString=WIFIToString+1;
    %}
    case 'UMTS' 
        NewNetwork(1,CostperByte)=60;
        NewNetwork(1,Security)= 70 ;
        if mod(UMTSToString,2) == 1
        NewNetwork(1,CostperByte)=80 ;
        NewNetwork(1,Security)= 90 ;
        end
        NewNetwork(1,DataRate)= (2-0.1).*rand(1,1) + 0.1;
        NewNetwork(1,PacketDelay)= ran(25,50);
        NewNetwork(1,PacketJitter)= ran(5,10);
        NewNetwork(1,PacketLoss)= ran(20,80);
        NetworksNames=[NetworksNames,"UMTS"+" "+int2str(UMTSToString)];
        UMTSToString=UMTSToString+1;
         %{
                NewNetwork(1,CostperByte)=ran(20,40) ;
        NewNetwork(1,Security)= ran(0,90) ;
        NewNetwork(1,DataRate)= ran(0.5,2);
        NewNetwork(1,PacketDelay)= ran(50,100);
        NewNetwork(1,PacketJitter)= ran(0.3,8);
        NewNetwork(1,PacketLoss)= ran(0,2);
                NetworksNames=[NetworksNames,"UMTS"+" "+int2str(UMTSToString)];
        UMTSToString=UMTSToString+1;
         %}
    case 'LTE'
        NewNetwork(1,CostperByte)= 40;
        if mod(WIMAXToString,2) == 1
        NewNetwork(1,CostperByte)=50 ;
        end
        NewNetwork(1,Security)= 60;
        NewNetwork(1,DataRate)= ran(2,100);
        NewNetwork(1,PacketDelay)= ran(50,300);
        NewNetwork(1,PacketJitter)= ran(3,12);
        NewNetwork(1,PacketLoss)= ran(20,80);
        NetworksNames=[NetworksNames,"LTE"+" "+int2str(LTEToString)];
        LTEToString=LTEToString+1;
        %{
        NetworksNames=[NetworksNames,"LTE"+" "+int2str(LTEToString)];
        LTEToString=LTEToString+1;
                NewNetwork(1,CostperByte)=ran(2,8) ;
        NewNetwork(1,Security)= ran(0,90) ;
        NewNetwork(1,DataRate)= ran(5,50);
        NewNetwork(1,PacketDelay)= ran(50,100);
        NewNetwork(1,PacketJitter)= ran(0,5);
        NewNetwork(1,PacketLoss)= ran(0,2);
    %}
        case 'FiveG'
        NewNetwork(1,CostperByte)= 100;
        if mod(WIMAXToString,2) == 1
        NewNetwork(1,CostperByte)=120 ;
        end
        NewNetwork(1,Security)= ran(80,90);
        NewNetwork(1,DataRate)= ran(100,120);
        NewNetwork(1,PacketDelay)= ran(0.1,2);
        NewNetwork(1,PacketJitter)= ran(0.1,12);
        NewNetwork(1,PacketLoss)= ran(1,10);
        NetworksNames=[NetworksNames,"5G"+" "+int2str(LTEToString)];
        LTEToString=LTEToString+1;
    otherwise 
        NewNetwork(1,CostperByte)= 40;
        if mod(WIMAXToString,2) == 1
        NewNetwork(1,CostperByte)=50 ;
        end
        NewNetwork(1,Security)= 60;
        NewNetwork(1,DataRate)= ran(1,60);
        NewNetwork(1,PacketDelay)= ran(60,100);
        NewNetwork(1,PacketJitter)= ran(3,10);
        NewNetwork(1,PacketLoss)= ran(20,80);
        NetworksNames=[NetworksNames,"WiMax"+" "+int2str(WIMAXToString)];
        WIMAXToString=WIMAXToString+1;     
  %{
         NetworksNames=[NetworksNames,"WiMax"+" "+int2str(WIMAXToString)];
        WIMAXToString=WIMAXToString+1;   
       NewNetwork(1,CostperByte)=ran(2,5) ;
        NewNetwork(1,Security)= ran(0,90) ;
        NewNetwork(1,DataRate)= ran(1,60);
        NewNetwork(1,PacketDelay)= ran(50,120);
        NewNetwork(1,PacketJitter)= ran(0,5);
        NewNetwork(1,PacketLoss)= ran(20,80);
        %}
end
end
function T = ran(min,max)
T= fix ((max-min).*rand(1,1) + min)+1;
end
Akzeptierte Antwort
  Cris LaPierre
    
      
 am 12 Jan. 2022
        Here is perhaps some starter code for you on how to create a MATLAB table.
rowNms = ["WIFI";"WIMAX";"UMTS";"LTE"];
varNms = ["CostperByte","Security","DataRate","PacketDelay","PacketJitter","PacketLoss"];
newNetwork = array2table(zeros(4,6), 'VariableNames', varNms);
newNetwork.Properties.RowNames = rowNms;
for r=1:height(newNetwork)
    for c = 1:width(newNetwork)
        newNetwork{r,c}=ran(randi(100,1),randi(100,1));
    end
end
newNetwork
function x = ran(min,max)
x= fix ((max-min).*rand(1,1) + min)+1;
end
16 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Performance and Memory finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



