Filter löschen
Filter löschen

What does this piece of psuedocode mean?

2 Ansichten (letzte 30 Tage)
Matt Amador
Matt Amador am 1 Nov. 2017
Kommentiert: Stephen23 am 1 Nov. 2017
Hello there, I was given psuedocode to implement into MATLAB, but i'm having a bit of trouble with this portion. Here is what it looks like, but I cannot tell how to implement what it's asking for in MATLAB. Can someone tell me what it means in code?

Antworten (1)

KSSV
KSSV am 1 Nov. 2017
G = round(rand(10)) ;
% sum of columns
sumG = sum(G,1) ;
% select s
s = sumG(randsample(10,1)) ;
% get c (column whose sum of columns is equal to c)
c = find(sumG==s) ;
% get r (zero's in the c column)
r = find(G(:,c)==0)
  1 Kommentar
Stephen23
Stephen23 am 1 Nov. 2017
Notes:
  • rather than round(rand(10)), simply use randi.
  • find is not required, linear indexing is more efficient.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Testing Frameworks 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!

Translated by