Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %Algebralaboration GUI - Anton Hagelberg
- clear all; clc; close all;
- load('BatMan.mat');
- f = figure('rend','painters','pos',[10 10 635 704]);
- axis off;
- %Button creation
- c1 = uicontrol(f,'Style','pushbutton','position',[555 75 50 25],...
- 'string','Load','Callback',@loadButton_callback);
- c2 = uicontrol(f,'Style','pushbutton','position',[555 115 50 26],...
- 'String', 'Rotate');
- c3 = uicontrol(f,'Style','pushbutton','position',[555 140 50 25],...
- 'String', 'Mirror');
- c4 = uicontrol(f,'Style','pushbutton','position',[555 170 50 25],...
- 'String','Scale');
- c5 = uicontrol(f,'Style','pushbutton','position',[545 260 90 25],...
- 'String','Scale and rotate','Callback',@scalerot_callback);
- c6 = uicontrol(f,'Style','pushbutton','position',[555 330 55 25],...
- 'String','Animate');
- %Textelements
- s1 = uicontrol(f,'Style', 'text','position',[410 120 120 15],...
- 'String','Degrees to rotate by:');
- s2 = uicontrol(f,'Style','text','position',[410 145 120 15],...
- 'String','K-value for mirror:');
- s3 = uicontrol(f,'Style','text','position',[360 175 140 15],...
- 'String','Alpha & Beta multiplicators:');
- %Textboxcreation
- t1 = uicontrol(f,'Style','edit','position',[525 115 30 25]);
- t2 = uicontrol(f,'Style','edit','position',[525 140 30 25]);
- t3 = uicontrol(f,'Style','edit','position',[530 170 25 25]);
- t4 = uicontrol(f,'Style','edit','position',[500 170 25 25]);
- %Callbacks for textbox-values
- set(c2,'Callback',@(src,event)rotation_callback(t1,src,event));
- set(c3,'Callback',@(src,event)mirror_callback(t2,src,event));
- set(c4,'Callback',@(src,event)scale_callback(t3,t4,src,event));
- set(c6,'Callback',@(src,event)animate_callback(src,event));
- %Load figure
- function loadButton_callback(src,event)
- load 'BatMan.mat' X
- subplot(2,2,3);
- PlotFigure(X);
- end
- %Rotation
- function rotation_callback(t1,src,event)
- load 'BatMan.mat' X
- subplot(2,2,1);
- fi = get(t1,'string');
- fi = str2double(fi);
- S = [cosd(fi),-sind(fi);sind(fi),cosd(fi)];
- A = mtimes(S,X);
- PlotFigure(A);
- end
- %Mirroring
- function mirror_callback(t2,src,event)
- load 'BatMan.mat' X
- subplot(2,2,1,'replace');
- k = get(t2,'string');
- k = str2double(k);
- m = 1/(1+k^2);
- S = m.*[1-k^2,2*k;2*k,k^2-1];
- A = mtimes(S,X);
- PlotFigure(A);
- end
- %Scaling
- function scale_callback(t3,t4,src,event)
- load 'BatMan.mat' X
- subplot(2,2,1,'replace');
- alpha = str2double(get(t3,'string'));
- beta = str2double(get(t4,'string'));
- S = [alpha,0;0,beta];
- A = mtimes(S,X);
- PlotFigure(A);
- end
- %Scaling and rotating
- function scalerot_callback(src,event)
- load 'BatMan.mat' X
- subplot(2,2,1,'replace');
- alpha = 2;
- beta = 2;
- fi = 30;
- S2 = [cosd(fi),-sind(fi);sind(fi),cosd(fi)];
- S1 = [alpha,0;0,beta];
- A1 = mtimes(S1,X);
- A2 = mtimes(S2,A1);
- PlotFigure(A2);
- end
- %Animation
- function animate_callback(src,event)
- load 'BatMan.mat' X
- fi = -180:180;
- subplot(2,2,1,'replace');
- for i = fi(1):fi(end)
- S = [cosd(i),-sind(i);sind(i),cosd(i)];
- A = mtimes(S,X);
- PlotFigure(A);
- pause(0.0001);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement