Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
% test for 'KRON' usage
fid = fopen(which('mykron'),'r');
c=onCleanup(@()fclose(fid));
tline=fgetl(fid);
while ischar(tline)
if (strfind(tline,'=kron')>0), error('Don''t use kron'); end
if (strfind(tline,' kron')>0), error('Don''t use kron'); end
if (strfind(tline,'+kron')>0)|(strfind(tline,'*kron')>0), error('Don''t use kron'); end
if (strfind(tline,'-kron')>0), error('Don''t use kron'); end
tline = fgetl(fid)
end;
tline =
''
tline =
[ma,na] = size(x);
tline =
[mb,nb] = size(y);
tline =
[ia,ib] = meshgrid(1:ma,1:mb);
tline =
[ja,jb] = meshgrid(1:na,1:nb);
tline =
z = x(ia,ja).*y(ib,jb);
tline =
''
tline =
end
tline =
''
tline =
%This code written by profile_id 33802
tline =
-1
|
2 | Pass |
%% test 1
x =1:3;
y =2:4;
y_correct = [2 3 4 4 6 8 6 9 12];
assert(isequal(mykron(x,y),y_correct))
|
3 | Pass |
%% test 2
x = randi(10,3,3);
y = 2:4;
z_correct = kron(x,y);
assert(isequal(mykron(x,y),z_correct))
|
1261 Solvers
835 Solvers
623 Solvers
Create One Large Eye of size N x N Quickly?
79 Solvers
4999 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!