-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatlab.html
More file actions
155 lines (147 loc) · 5.16 KB
/
Copy pathMatlab.html
File metadata and controls
155 lines (147 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html lang = "en">
<head>
<link rel="stylesheet" href="style.css">
<title>MatLab | Roll.IT</title>
<link rel="shortcut icon" href="logowhite.png" />
</head>
<body>
<a href="chatbot.html">
<img src="box.png" alt="chat" class = "pos"/> </a>
<div class = "header1">
<table>
<tr>
<td><img src="logo.png" alt = "Roll.IT" class = "logo"></td>
<td class="tableHeader"><a href="index.html">Hjem</a></td>
<td class="tableHeader"><a href="kart.html">Kart</a></td>
<td class="tableHeader"><a href="info.html">Info</a></td>
<td class="tableHeader"><a href="priser.html">Priser</a></td>
<td class="tableHeader"><a href="prosjekt.html">Prosjekt</a></td>
<td class="tableHeader"><a href="Matlab.html">Matlab</a></td>
<td class="tableHeader"><a href="OmOss.html">Om oss</a></td>
</tr>
</table>
</div>
<div class="text start">
<h1>Kildekode:</h1>
<p>
function simple_gui2
<br>
n = 0;
<br>
f = figure('Position',[300,300,900,600]);<br>
h = [];<br>
h(1) = uicontrol('Style','popupmenu','String',{'Peaks','Membrane','Sinc','Dalen','Spesiell'},'Position',[690,20,200,50],'Callback',@popup_menu_Callback);<br>
h(2) = axes('Units','pixels','Position',[50,40,510,510]);<br>
h(3) = uicontrol('Style','pushbutton','String','Rotate','Position',[690,80,200,50],'Callback',@rot_Callback);<br>
h(4) = uicontrol('Style','pushbutton','String','Top view','Position',[690,140,200,50],'Callback',@top_Callback);<br>
h(5) = uicontrol('Style','pushbutton','String','Left','Position',[690,200,100,50],'Callback',@left_Callback);<br>
h(6) = uicontrol('Style','pushbutton','String','Right','Position',[790,200,100,50],'Callback',@right_Callback);<br>
h(7) = uicontrol('Style','pushbutton','String','Start','Position',[690,260,100,50],'Callback',@start_Callback);<br>
h(8) = uicontrol('Style','pushbutton','String','Stopp','Position',[790,260,100,50],'Callback',@stopp_Callback);<br>
<br>
tmr = timer ('ExecutionMode','FixedRate','Period', 1.01, 'TimerFcn', {@rot_Callback});<br>
<br>
f.Units = 'normalized';<br>
set(h, 'Units', 'normalized');<br>
set(h, 'FontSize', 12);<br>
<br>
peaks_data = peaks(35);<br>
membrane_data = membrane;<br>
[x,y] = meshgrid(-15:.5:15);<br>
z = sqrt(x.^2+y.^2) + eps;<br>
sinc_data = sin(z)./z;<br>
rarFig_data = sin(z)./z + tan(z);<br>
t = 0:pi/10:2*pi;<br>
sylinder_data = cylinder(2+cos(t));<br>
<br>
[y, Fs] = audioread('engine.wav');<br>
<br>
player = audioplayer(y, Fs);<br>
<br>
current_data = peaks_data;<br>
s = surf(current_data);<br>
<br>
function popup_menu_Callback(source,eventdata)<br>
str = get(source, 'String');<br>
val = get(source,'Value');<br>
<br>
switch str{val};<br>
case 'Peaks' % User selects Peaks.<br>
current_data = peaks_data;<br>
x = [-2 42];<br>
y = [-2 42];<br>
z = [-10 20];<br>
case 'Membrane'
current_data = membrane_data;<br>
x = [-4 36];<br>
y = [-4 36];<br>
z = [-2 4];<br>
case 'Sinc'<br>
current_data = sinc_data;<br>
x = [-10 70];<br>
y = [-10 70];<br>
z = [-10 20];<br>
case 'Spesiell'<br>
current_data = rarFig_data;<br>
x = [-10 70];<br>
y = [-10 70];<br>
z = [-230 50];<br>
case 'Dalen'<br>
current_data = sylinder_data;<br>
x = [-1 25];<br>
y = [-1 25];<br>
z = [-10 20];<br>
end<br>
s = surf(current_data);<br>
xlim(x);<br>
ylim(y);<br>
zlim(z);<br>
<br>
end<br>
function rot_Callback(obj, ev)<br>
rotate(s, [0 0 1], 5);<br>
direction = [0 0 1];<br>
rotate(s, direction, n);<br>
n = n + 1;<br>
end<br>
function top_Callback(obj, ev)<br>
view(2);<br>
end<br>
function right_Callback(obj, ev)<br>
view(0,0);<br>
view(90,0);<br>
end<br>
function left_Callback(obj, ev)<br>
view(0,0);<br>
view(-90,0);<br>
end<br>
function start_Callback(obj, ev)<br>
play(player);<br>
<br>
start(tmr);<br>
end<br>
function stopp_Callback(obj, ev)<br>
pause(player);<br>
<br>
stop(tmr);<br>
end<br>
xlim([-2 42]);<br>
ylim([-2 42]);
zlim([-10 20]);<br>
end<br>
</p>
<h1>Skjermbilder:</h1>
<br>
<img src="MatLab1.png" alt="MatLab1"/>
<br>
<img src="MatLab2.png" alt="MatLab2"/>
<br>
<img src="MatLab3.png" alt="MatLab3"/>
</div>
<br>
<br>
<br>
<br>
</body>
</html>