Info
This question is closed. Reopen it to edit or answer.
could anyone help me to fix the issue
1 view (last 30 days)
Show older comments
I am using the command randi(4,4,1) it gives the output
ans =
1
1
1
3
Could anyone tell me how to get the output in the following manner
ans=
1
2
3
4
4 Comments
Answers (3)
Walter Roberson
on 30 Apr 2018
s = struct('Type', 'twister', 'Seed', 1, 'State', ...
uint32([2629073562; 2983301384; 681580311; 4033622241; 792772838; 3306961981; 92883131; 1785085746; 3364128315; 2402025379; 3224868746; 1145213362; 3784365245; 1948434636; 2667646161; 2598854474; 921967201; 1345782310; 4019597455; 2906395199; 1349669984; 2676817993; 4201769589; 2002781766; 3540177092; 4224925813; 3661313599; 1709930435; 1812273278; 2973452884; 1592291796; 3452239013; 3588672187; 3228651068; 3191454495; 3286135343; 2640545275; 3096953148; 3746505897; 2292163827; 2164382601; 1581410039; 2413832827; 2536571847; 179684232; 1638923698; 3155158821; 1454330362; 4050607484; 607322300; 2216566078; 597866774; 1036426282; 732815996; 3131865469; 2440339870; 2814550949; 1479383443; 2449469876; 3810238677; 2923086221; 437801529; 2891199990; 1886893516; 3898673786; 376204646; 1392372379; 4123661669; 1140754642; 3539167101; 2386309702; 3740957436; 4033654965; 1720449988; 3434980330; 4213508374; 3576835843; 2818865106; 1653162115; 2935588114; 3870616539; 102614847; 1476834675; 1220770796; 1233652508; 2385138085; 1300608482; 2753953039; 262993567; 4009374062; 2143978386; 1613109469; 3072671496; 1223816410; 4088822114; 3382188205; 2250056281; 1926821318; 3806317775; 2882166470; 94227745; 2877123406; 1030225246; 1555072155; 95009460; 1855512191; 2840453856; 2478087736; 836340051; 1566383306; 2625414289; 3519123538; 840509954; 2373484829; 676528503; 2783662465; 3557034492; 2566048980; 2347785709; 3566819907; 1311855742; 198269976; 2693520819; 2127070362; 961491174; 3932714317; 837664826; 4277891831; 3535515583; 2831416447; 3505045078; 3763313683; 367436315; 3614057572; 3780746374; 2693039652; 2297021184; 2224934154; 698822522; 2718629137; 1175446314; 2603507610; 2067589016; 2280810156; 2037033584; 3956938481; 1112874779; 3264939860; 2054107185; 2354026721; 1958640221; 2844284824; 3775753525; 2462549847; 3562644229; 3683686884; 3714884555; 2266356233; 2808583945; 980888698; 1137581788; 2771236582; 1975939317; 1605707990; 614167064; 767063856; 4227905160; 3590303986; 2932373212; 2230415839; 127157074; 2328724316; 3356372094; 3215726425; 282321962; 4226412442; 106823192; 3925701436; 610765913; 281952627; 1832011890; 2670621135; 1012800992; 1489632964; 1371755819; 2529629289; 607643288; 3941535311; 3202770816; 284461833; 3696778854; 325625733; 2671656400; 1391137252; 1240723705; 3132941411; 314202987; 1301784708; 2575857120; 313287791; 3569720512; 981744121; 2986286440; 1051168756; 3881027887; 1088809168; 3421075971; 2655923113; 2577977181; 3968201444; 1406585576; 4001025594; 1854233928; 3825832114; 954907921; 3109212504; 1706316388; 1550715292; 2934259476; 1892992132; 4050317728; 4110743408; 359920673; 3542060425; 597068400; 843058885; 3799566677; 2064802063; 860032883; 2732673041; 3457529378; 3660165513; 1125914118; 4212233956; 3757086488; 2632116865; 462233764; 161423763; 141910303; 2265109737; 1983126147; 2231395445; 2147383559; 611750005; 2194081082; 1699618892; 3841025952; 1294478167; 936120505; 4102008957; 4268194620; 1994019922; 1187332833; 3953675561; 1917283619; 896867387; 1634068959; 3950876764; 485558549; 45383166; 2795959904; 1717914918; 3449856475; 3796449494; 3318166191; 1007512487; 480498390; 1730605673; 3972660041; 2287008439; 539639323; 1569683418; 3795864463; 453065119; 2449404120; 265049099; 3514892628; 2665563904; 2534523080; 1969344934; 4294466702; 1478959417; 1858551310; 3029422620; 4121720519; 2933843154; 3209557296; 3111170404; 4264711934; 2448282623; 1388503581; 1999436060; 818418468; 3283991819; 2356924521; 2684567658; 1424193429; 1187340812; 3847120877; 1987859863; 1879502046; 3422594099; 1419478013; 4148487199; 2538837125; 3694851522; 636350498; 1097832595; 3779331880; 351970715; 2534774459; 3389311029; 3762283879; 3742425828; 3882821767; 2683353; 1981273229; 4068324016; 539226467; 2411256222; 1780609115; 2059099269; 2889497980; 1123848930; 540086248; 3467353606; 3362203896; 4058078927; 93044840; 426751932; 824266620; 3444590461; 2122918776; 3339845861; 4233923286; 3733051177; 2957657929; 3110908772; 2551930098; 1294126893; 2213336821; 2124571119; 49780221; 2901327722; 2493306969; 2545470627; 102527300; 3876142393; 4097726412; 3510695954; 660912408; 2033930425; 1601509561; 969180562; 635252598; 177954239; 3054207519; 4122051269; 2787463443; 1664731394; 2907371963; 1484884283; 1560546623; 2902374922; 2395942225; 451352804; 3346805556; 3459298550; 3482428591; 10753957; 4101820340; 3306178891; 1122941824; 355877597; 1683964498; 238724805; 3926649337; 3197046734; 4277634633; 2288745211; 4202067531; 526022968; 4017453944; 1499184106; 2677441952; 2227353703; 1995296581; 1690255681; 2920887680; 605849491; 3072795503; 746910746; 2709796449; 1225135658; 657841564; 4070363626; 144842260; 3718575695; 3159187032; 88291794; 3129049475; 410962657; 1728726693; 2397606939; 4126386549; 751549633; 4226219908; 1549973222; 3060733996; 3741110422; 2530947598; 2627897488; 2317706652; 1170828427; 2671701715; 1153351468; 3762293788; 4093330405; 1641962571; 699324101; 3173743570; 1798831929; 3467616712; 4198420524; 2448981354; 499920867; 968642107; 2140815539; 4193124145; 1639223168; 284638153; 396985542; 3543438633; 237854258; 3938010494; 24441053; 2947436871; 1273496002; 719279415; 3574242559; 1040109604; 3849196601; 3250223302; 3411729501; 3031943234; 2932285520; 2932420675; 2011314805; 2480850074; 3207806491; 462404995; 3279042455; 4270524229; 1064389665; 1894847490; 721365878; 357178131; 2827490451; 2604438657; 242514037; 678802395; 1322770750; 2747624534; 4246466163; 4188936761; 1207204018; 980275996; 841637218; 1468131552; 4102349079; 586888764; 3105466755; 1628818384; 2991889790; 2801191520; 2114916962; 1124291831; 3242113092; 1082871720; 3625937786; 2796251125; 1651820702; 3427511545; 2035120316; 1024058911; 4209506140; 2527167744; 213886228; 2514956543; 2450260579; 327684603; 3444379103; 3884997363; 2844468873; 2261078634; 3926825101; 439487268; 3789435080; 1212963762; 4259079565; 2772611204; 2534236055; 2430244594; 916922266; 903950702; 3381351589; 2268543712; 3616954837; 1273083041; 1682465785; 1342921678; 2593265787; 3033724173; 2988544460; 1824668777; 1214999983; 257453352; 4187931679; 3523379959; 1481153225; 4290295859; 220376185; 4136013972; 511679284; 3510589272; 1404047266; 3712771231; 2125374725; 32037606; 3601685135; 3433623522; 841138647; 1610171318; 3920699442; 1084892922; 3146108732; 3672652561; 1148331655; 2473777375; 3039860130; 1170979324; 575756423; 1389255297; 339011744; 2351938991; 4050094885; 2773634239; 3715040333; 3920910597; 562407139; 29887881; 1623822350; 358193390; 1822261341; 1243290919; 755541153; 153529770; 994467513; 1339524978; 3174283928; 2782204324; 182251010; 1833692038; 3477775846; 2820237500; 2165639585; 4089211432; 4010345846; 1238643345; 3710224584; 2251039304; 1196168985; 3165387311; 3920626153; 1796963839; 2112227260; 3358845388; 593715887; 3046897033; 2968478428; 3846781604; 3565923316; 2452128692; 68338106; 1427007580; 2192917968; 75235680; 2134869635; 1857807303; 3745016485; 2601327385; 35512535; 559792668; 2093376088; 939608650; 2259549051; 2605376692; 2058599240; 2980581379; 3160415220; 2739135905; 254886981; 1652380747; 371107437; 1123937393; 4185309254; 864314942; 2739416220; 2185572068; 1163546293; 3491702910; 996401156; 1198755052; 2898003956; 745796080; 4127642404; 4237523457; 1274635091; 3144139009; 1600421663; 4226154574; 538248802; 373236455; 116925273; 256]) );
rng(s);
randi(4, 4, 1)
12 Comments
Walter Roberson
on 30 Apr 2018
matchtable = cell(4,4,4,4);
for K = 0 : 2^16-1
rng(K);
thisrnd = num2cell(randi(4,4,1));
idx = sub2ind([4, 4, 4, 4], thisrnd{:});
if isempty(matchtable{idx}); matchtable{idx} = K; end
if ~any(cellfun(@isempty,matchtable(:))); break; end
end
if K == 2^16-1
fprintf('Did not find some combinations\n');
else
fprintf('Done at seed %d\n', K);
end
Afterwards, if all goes well, then matchtable{A,B,C,D} is the lowest-number seed for rng() such that rng(matchtable{A,B,C,D}); randi(4,4,1) gives [A;B;C;D] . Thus if the task is to prove that all possible combinations can be generated at some point, then this finds the seeds that do that.
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!