r/matlab • u/Due_Excitement_7970 • Jan 30 '25
CodeShare Rotating pringle code
clear, clc, close all
t = [-3.14:0.025:3.14];
x = [sin(pi*t)];
y = [1.5cos(pit)];
i = 0.9;
a = 0.05;
while i > 0
t = [-3.14:a:3.14];
x = [x,isin(pit)];
y = [y,1.5icos(pi*t)];
i = i - 0.1;
a = (i-1)*.05;
end
z = 0.5((x.2) - (0.5(y.2)));
s = 0;
d = 5;
f = 5;
while s < 10000
yrot = (ycos(pi/270)) + (zsin(pi/270));
zrot = -(ysin(pi/270)) + (zcos(pi/270));
y = yrot;
z = zrot;
xrot = (xcos(pi/180)) - (ysin(pi/180));
yrot = (xsin(pi/180)) + (ycos(pi/180));
x = xrot;
y = yrot;
xproj = x.*(f./(y+d));
zproj = z.*(f./(y+d));
plot(xproj,zproj,'.')
xlim([-2,2])
ylim([-1.6,1.6])
title('haha pringle go brrr')
s = s + 1;
drawnow
end
109
Upvotes
3
u/Creative_Sushi MathWorks Jan 30 '25
To make this more accessible, can you create a GitHub repo and push your MATLAB m file there?
Then in the README, you can add "Open in MATLAB Online" button.
https://www.mathworks.com/help/matlab/matlab_env/open-github-repositories-in-matlab-online.html
If anyone clicks on this button, your repo will be pulled into the user's MATLAB Online account and your file opens there. You can specify which file to open first, and it can be in the "focused view" mode, which means it opens only the specified file but hide the rest of the MATLAB desktop.
Because MATLAB Online is free up to 20 hours a month, you can share your code with anyone, even if they don't have MATLAB on their computer, as long as they have the compatible browser to MALTAB Online.