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 visualizzazioni (ultimi 30 giorni)
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 Commenti
Cris LaPierre
Cris LaPierre il 11 Gen 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

Accedi per commentare.

Risposta accettata

Cris LaPierre
Cris LaPierre il 12 Gen 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
newNetwork = 4×6 table
CostperByte Security DataRate PacketDelay PacketJitter PacketLoss ___________ ________ ________ ___________ ____________ __________ WIFI 21 47 46 70 61 39 WIMAX 17 57 52 58 80 55 UMTS 65 57 36 51 62 29 LTE 30 29 32 72 19 71
function x = ran(min,max)
x= fix ((max-min).*rand(1,1) + min)+1;
end
  16 Commenti
ARAM KHURSHEED
ARAM KHURSHEED il 13 Gen 2022
Exactly, I have to do that, I have no choice, I want to deal withe values inside the table, I will need only the network names (row names) in the end and at that time I have to think about that.
I am doing network ranking.
So, in the last i will need name of network but whole program is not ready, i am doing it partly(script by script).
Best Regards,

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Performance and Memory in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by