- /
-
who is writing matlab code ?
on 20 Oct 2024
- 20
- 168
- 0
- 1
- 1386
Cite your audio source here (if applicable): Drones & Textures3_EP.wav, https://leftbank-cafe.com/etc/freeloops/free_loops.html
drawframe(96);
Write your drawframe function below
function drawframe(f)
funcStr = {'[X,Y,Z] = peaks(25);'
'CO(:,:,1) = zeros(25); % red'
'CO(:,:,2) = ones(25).*linspace(0.5,0.6,25); % green'
'CO(:,:,3) = ones(25).*linspace(0,1,25); % blue'
'surf(X,Y,Z,CO)'
'for i = 1:10'
' view(-37.5 + i,90)'
' drawnow'
'end'};
figure()
ax = gca;
ax.NextPlot = 'add';
ax.XColor = 'none';
ax.YColor = 'none';
ax.XLim = [0,1];
ax.YLim = [0,1];
n = 0;
for i = 1:length(funcStr)
txtHdl = text(1/50, (length(funcStr) - i + .5)/length(funcStr),'1');
for j = 1:length(funcStr{i})
tStr = [funcStr{i}(1:j),' |'];
ind = regexpi(tStr,'%');
if ~isempty(ind)
tStr = [tStr(1:ind-1),'{\color[rgb]{0 .502 .0745}',tStr(ind:end-1),'} |'];
end
ind = regexpi(tStr,'for');
if ~isempty(ind)
tStr = [tStr(1:ind-1),'{\color[rgb]{.0549 0 1}for}',tStr(ind+3:end)];
end
ind = regexpi(tStr,'end');
if ~isempty(ind)
tStr = [tStr(1:ind-1),'{\color[rgb]{.0549 0 1}end}',tStr(ind+3:end)];
end
if j == length(funcStr{i})
tStr(end) = [];
end
txtHdl.String = tStr;
n = n + 1;
if f*4 < n
return
end
end
end
if f > 47
surf([0,1;0,1].*.7+.3,[0,0;1,1].*.7,[1,1;1,1].*.01,'FaceColor','w','EdgeColor','k')
end
[X,Y,Z] = peaks(25);
X = rescale(X,0.4,.9);
Y = rescale(Y,0,1);
Z = rescale(Z,.1,.6);
CO(:,:,1) = zeros(25);
CO(:,:,2) = ones(25).*linspace(0.5,0.6,25);
CO(:,:,3) = ones(25).*linspace(0,1,25);
surfHdl = surf(X,Z,Y,CO);
i = f - 48;
NX = (X - .65)./.5;
NY = (Y - .5);
surfHdl.XData = .5.*(NX.*cos(i*pi/40) - NY.*sin(i*pi/40)) + .65;
surfHdl.ZData = NX.*sin(i*pi/40) + NY.*cos(i*pi/40) + .5;
end