📄 w5_ed_sm.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% w5_edit_smooth.m
%
% jmw
% 6/20/94
%
% User-Specified Maps: Edit Window
% this checks requests and requirements for smoothing and
% smooths user-map (i.e. connect the target dots) if necessary
%
% Kind of serves two purposes: (1) as a callback for smooth
% button, and (2) as a general purpose program to assess if smoothing
% is req'd and re-display if necessary ...
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SMOOTHVALUE = get(w5_edit_smooth_h,'Value');
if (SMOOTHVALUE == OLDSMOOTHVALUE & TARGET_SMOOTH == 0)
;
% do nothing, same value, no change, AND no request for smoothing
else
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% automatically adjust Smoothing method if Poly Order is too high
% for the number of targets
if (TARGETVALUE == 1 & SMOOTHVALUE > 2)
SMOOTHVALUE = 2;
set(w5_edit_smooth_h,'Value',SMOOTHVALUE);
elseif (TARGETVALUE == 2 & SMOOTHVALUE > 3)
SMOOTHVALUE = 3;
set(w5_edit_smooth_h,'Value',SMOOTHVALUE);
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% make "smooth" user waveform
if (SMOOTHVALUE == 1 )
% no smoothing; piecewise straight
[t_m,t_n]=size(target);
for i=1:t_m-1,
top_y = target(i+1,2);
bottom_y = target(i,2);
top_x = target(i+1,1);
bottom_x = target(i,1);
target_slope = (top_y -bottom_y) / (top_x - bottom_x);
for j=bottom_x:(top_x - 1),
%user(j) = ( (target_slope * (j-bottom_x)));
user(j) = (target_slope*(j-bottom_x)) + bottom_y;
end;
end;
user(100) = target(t_m,2);
elseif (SMOOTHVALUE == 2 )
% linear
SMOOTHORDER = 1;
SMPOLY = polyfit(target(:,1),target(:,2), SMOOTHORDER);
user = polyval(SMPOLY, [1:1:100]);
elseif (SMOOTHVALUE == 3 )
% 2nd order poly
SMOOTHORDER = 2;
SMPOLY = polyfit(target(:,1),target(:,2), SMOOTHORDER);
user = polyval(SMPOLY, [1:1:100]);
elseif (SMOOTHVALUE == 4 )
% 3rd order poly
SMOOTHORDER = 3;
SMPOLY = polyfit(target(:,1),target(:,2), SMOOTHORDER);
user = polyval(SMPOLY, [1:1:100]);
elseif (SMOOTHVALUE == 5 )
% 4th order poly
SMOOTHORDER = 4;
SMPOLY = polyfit(target(:,1),target(:,2), SMOOTHORDER);
user = polyval(SMPOLY, [1:1:100]);
elseif (SMOOTHVALUE == 6 )
% 5th order poly
SMOOTHORDER = 5;
SMPOLY = polyfit(target(:,1),target(:,2), SMOOTHORDER);
user = polyval(SMPOLY, [1:1:100]);
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OLDSMOOTHVALUE = SMOOTHVALUE; % reset
TARGET_SMOOTH = 0;
end; % end: if (SMOOTHVALUE == OLDSMOOTHVALUE)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% turn buttons on if NOT the first time window opened
if (FRESHOPENW5 == 1)
FRESHOPENW5 = 0;
else
set(w5_edit_update_h,'Visible','on');
set(w5_edit_cancel_h,'Visible','on');
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
w5_ed_di
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear top_x top_y bottom_x bottom_y target_slope new_target
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -