⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coe_gui.m

📁 空空导弹设计
💻 M
📖 第 1 页 / 共 2 页
字号:
if isnan(v)    set(hObject, 'String', 0);    errordlg('Input must be a number','Error');end% Save the new density valuehandles.coe.v = v;guidata(hObject,handles)end% --- Executes during object creation, after setting all properties.function edit_v_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_v (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endend% --- Executes on button press in plot_orbit.function plot_orbit_Callback(hObject, eventdata, handles)% hObject    handle to plot_orbit (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Author: Anders Edfors% Date: 2008-03-23% Version: 1.0% Email: anders.edfors@ssc.se%% Orbit is blue if it is a direct orbit and red if its retrograded%a = handles.coe.a;e = handles.coe.e;inc = handles.coe.inc;omega = handles.coe.omega;w = handles.coe.w;v = handles.coe.v;r = handles.coe.r;[x,y,z] = orbit(a, e, omega*pi/180, inc*pi/180, w*pi/180);[xv,yv,zv] = trueanomaly(a,e,omega*pi/180,inc*pi/180,w*pi/180,v*pi/180);[xp,yp,zp] = planet(r,20); % earth radius ( km )if( inc > 90 )    orbit_color = 'red'; % retrogradeelseif (inc == 90 || inc == 180 )    orbit_color = 'black'; % polarelse     orbit_color = 'blue'; % directendplot3(x,y,z,orbit_color,'Linewidth',2); % directaxis equalhold onplot3(xv,yv,zv,'blacko','Linewidth',2); % plot true anomalysurf(xp,yp,zp,'EdgeAlpha',0.4);   % plot the planetcolormap([0  0.5  0.8]);scale = 2;axis([-scale*a scale*a -scale*a scale*a -scale*a scale*a])% Get Axis properties axis_data = get(gca);xmin = axis_data.XLim(1);xmax = axis_data.XLim(2);ymin = axis_data.YLim(1);ymax = axis_data.YLim(2);zmin = axis_data.ZLim(1);zmax = axis_data.ZLim(2);% I, J ,K vectorsplot3([xmin,xmax],[0 0],[0 0],'black','Linewidth',1); plot3(xmax,0,0,'black>','Linewidth',1.5);plot3([0 0],[ymin,ymax],[0 0],'black','Linewidth',1); plot3(0,ymax,0,'blue>','Linewidth',1.5);plot3([0 0],[0 0],[zmin,zmax],'black','Linewidth',1); plot3(0,0,zmax,'red^','Linewidth',1.5);% right ascending node line plotxomega_max = xmax*cos(omega*pi/180);xomega_min = xmin*cos(omega*pi/180);yomega_max = ymax*sin(omega*pi/180);yomega_min = ymin*sin(omega*pi/180);xlabel('I');ylabel('J');zlabel('K');plot3([xomega_min xomega_max], [yomega_min yomega_max], [0 0], 'g','Linewidth',1.5);% add equatorial planxe = [xmin xmax;xmin xmax]; ye = [ymax ymax;ymin ymin]; ze = [0 0; 0 0];eq_alpha = 0.3; % transparancy mesh(xe,ye,ze,'FaceAlpha',eq_alpha,'FaceColor',[0.753,0.753,0.753]);grid onhold offendfunction edit_r_Callback(hObject, eventdata, handles)% hObject    handle to edit_r (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit_r as text%        str2double(get(hObject,'String')) returns contents of edit_r as a doubler = str2double(get(hObject,'String'));if isnan(r)    set(hObject, 'String', 0);    errordlg('Input must be a number','Error');end% Save the new density valuehandles.coe.r = r;guidata(hObject,handles)end% --- Executes during object creation, after setting all properties.function edit_r_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_r (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endend%% Utility function% Anders Edfors%function [x,y,z] = trueanomaly(a,e,omega,inc,w,v)%% a: semimajor axis% e: excentricity% i: inclination% w: argument of perigee% v: true anomaly%% 2-body problem orbit determinationr = a*(1-e^2)./(1+e*cos(v));x = r.*cos(v);y = r.*sin(v);z = zeros(1,length(x));[x,y,z] = pointrot_oiw(x,y,z,omega,inc,w);endfunction [x,y,z] = orbit(a,e,omega,inc,w,n)%% orbit(a,e,i)%% a: semimajor axis% e: excentricity% i: inclination% w: argument of perigee% n: number of points [optional]if (nargin == 5 )    n = 100; % Defaultendif (nargin == 0 || nargin > 6)    fprintf(1,'error -> wrong number of arguments\n');    return;end% v = true anomalyv = 0:2*pi/n:2*pi;% 2-body problem orbit determinationr = a*(1-e^2)./(1+e*cos(v));x = r.*cos(v);y = r.*sin(v);z = zeros(1,length(x));[x,y,z] = pointrot_oiw(x,y,z,omega,inc,w);endfunction [x2,y2,z2] = pointrot_oiw(x1,y1,z1,omega,inc,w)%% pointrot_oiw(omega,inc,w)%% omega: right ascension angle% inc : inclination angle% w : argument of perigee angle%% point rotation in the plane ( frame fixed )%%  Rz(omega)*Rx(inc)*Rz(w)%Mrot = [cos(omega) * cos(w) - sin(omega) * cos(inc) * sin(w) -cos(omega) * sin(w) - sin(omega) * cos(inc) * cos(w) sin(omega) * sin(inc);         sin(omega) * cos(w) + cos(omega) * cos(inc) * sin(w) -sin(omega) * sin(w) + cos(omega) * cos(inc) * cos(w) -cos(omega) * sin(inc);         sin(inc) * sin(w) sin(inc) * cos(w) cos(inc);];RotResult = Mrot*[x1;y1;z1];    x2 = RotResult(1,:);y2 = RotResult(2,:);z2 = RotResult(3,:);endfunction [x,y,z] = planet(r,n)%% planet_sphere(r,[n])% % r = radius% n = number of points ( optional )%% author: Anders Edfors Vannevik%if (nargin == 1 )    n = 20; % Defaultendif (nargin == 0 || nargin > 2)    fprintf(1,'error -> wrong number of arguments\n');    return;end[x1,y1,z1] = sphere(n);x = r.*x1;y = r.*y1;z = r.*z1;end% --- Executes on button press in zoom_button.function zoom_button_Callback(hObject, eventdata, handles)% hObject    handle to zoom_button (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)zoom on;end% --- Executes on button press in rotate_button.function rotate_button_Callback(hObject, eventdata, handles)% hObject    handle to rotate_button (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)rotate3d on;end% --- Executes on button press in hold_button.function hold_button_Callback(hObject, eventdata, handles)% hObject    handle to hold_button (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)hold on;end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -