# compressing a code, help me

6 views (last 30 days)
Cauli Vilela Ferreira on 2 Jul 2020
Answered: Image Analyst on 2 Jul 2020
Any one knows how to compress this code as much as possible?
for VetorN = fix((20*sqrt(2).^(0:5)))
[row,col] = size(VetorN);
i = (1: col);
discSt.N = VetorN(i);
VN = VetorN;
CD0 = VetorN *3;
if VetorN == 20
CD01 = CD0;
elseif VetorN == 28
CD02 = CD0;
elseif VetorN == 40
CD03 = CD0;
elseif VetorN == 56
CD04 = CD0;
else
CD05 = CD0;
end
pause()
end
MCD0 = [CD01 CD02 CD03 CD04 CD05]

madhan ravi on 2 Jul 2020
Why do you use pause()?
Cauli Vilela Ferreira on 2 Jul 2020
because generate a plot after each pause

madhan ravi on 2 Jul 2020
VetorN = fix( (20 * sqrt(2) .^ (0 : 5) ) )
MD0 = VetorN * 3;
MD0(end - 1) = [ ]

Show 1 older comment
madhan ravi on 2 Jul 2020
VetorN = fix( (20 * sqrt(2) .^ (0 : 5) ) );
MD0 = zeros(1, numel(VectorN);
for k = 1 : numel(VetorN)
MD0(k) = VetorN(k) * 3;
end
MD0(end - 1) = [ ]
Cauli Vilela Ferreira on 2 Jul 2020
How cant i add VetorN(1,5), i forgot to put in the code
for VetorN = fix((20*sqrt(2).^(0:5)))
[row,col] = size(VetorN);
i = (1: col);
discSt.N = VetorN(i);
VN = VetorN;
CD0 = VetorN *3;
if VetorN == 20
CD01 = CD0;
elseif VetorN == 28
CD02 = CD0;
elseif VetorN == 40
CD03 = CD0;
elseif VetorN == 56
CD04 = CD0;
elseif VetorN== 80
CD05 = CD0;
else
CD06 = CD0;
end
pause()
end
MCD0 = [CD01 CD02 CD03 CD04 CD05 CD06]
madhan ravi on 2 Jul 2020
So remove the last line in my code ;)