📄 gridsimulation.m
字号:
xx=round(x-0.5);
yy=round(y-0.5);
Grid(xx,yy)=1;
xx=xx/GridNumber;
yy=yy/GridNumber;
XX=linspace(xx,xx+1/GridNumber,100);
YY=linspace(yy+1/GridNumber,yy+1/GridNumber,100);
hold on
handleArea=area(XX,YY,yy);
end
% --- Executes on button press in Run.
function Run_Callback(hObject, eventdata, handles)
% hObject handle to Run (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.StartPoint,'Enable','off')
set(handles.EndPoint,'Enable','off')
set(handles.Obstacle,'Enable','off')
set(handles.Start,'Enable','on')
k=1
% --- Executes on button press in Rerun.
function Rerun_Callback(hObject, eventdata, handles)
% hObject handle to Rerun (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in Exit.
function Exit_Callback(hObject, eventdata, handles)
% hObject handle to Exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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');
end
% --------------------------------------------------------------------
function File_Callback(hObject, eventdata, handles)
% hObject handle to File (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function TwoPoint_Callback(hObject, eventdata, handles)
% hObject handle to TwoPoint (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function TwoPointSim_Callback(hObject, eventdata, handles)
% hObject handle to TwoPointSim (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Grid_Callback(hObject, eventdata, handles)
% hObject handle to Grid (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function NN_Callback(hObject, eventdata, handles)
% hObject handle to NN (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function FNN_Callback(hObject, eventdata, handles)
% hObject handle to FNN (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in GridNumber.
function GridNumber_Callback(hObject, eventdata, handles)
% hObject handle to GridNumber (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global GridNumber;
PromptStr={'请输入栅格数量(大于10小于50)'};
DefNumber={'20'};
AnswerNumber=InputDlg(PromptStr,'设置栅格数量',1,DefNumber);
GridNumber=str2num(AnswerNumber{1});
cla
DrawRectangle(GridNumber);
% --- Executes on button press in StartPoint.
function StartPoint_Callback(hObject, eventdata, handles)
% hObject handle to StartPoint (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global GridNumber;
set(handles.StartPoint,'Enable','off')
set(handles.EndPoint,'Enable','on')
set(handles.Obstacle,'Enable','off')
set(handles.Start,'Enable','off')
[x,y,k]=ginput(1);
x=x*GridNumber;y=y*GridNumber;
xx=round(x-0.5);
yy=round(y-0.5);
Grid(xx,yy)=1;
xx=xx/GridNumber;
yy=yy/GridNumber;
XX=linspace(xx,xx+1/GridNumber,100);
YY=linspace(yy+1/GridNumber,yy+1/GridNumber,100);
hold on
handleArea=area(XX,YY,yy);
% --- Executes on button press in EndPoint.
function EndPoint_Callback(hObject, eventdata, handles)
% hObject handle to EndPoint (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.StartPoint,'Enable','off')
set(handles.EndPoint,'Enable','off')
set(handles.Obstacle,'Enable','on')
set(handles.Start,'Enable','off')
global GridNumber;
[x,y,k]=ginput(1);
x=x*GridNumber;y=y*GridNumber;
xx=round(x-0.5);
yy=round(y-0.5);
Grid(xx,yy)=1;
xx=xx/GridNumber;
yy=yy/GridNumber;
XX=linspace(xx,xx+1/GridNumber,100);
YY=linspace(yy+1/GridNumber,yy+1/GridNumber,100);
hold on
handleArea=area(XX,YY,yy);
% --- Executes on button press in Obstacle.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to Obstacle (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in Start.
function Sart_Callback(hObject, eventdata, handles)
% hObject handle to Start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in ReStart.
function ReStart_Callback(hObject, eventdata, handles)
% hObject handle to ReStart (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in GridFigExit.
function GridFigExit_Callback(hObject, eventdata, handles)
% hObject handle to GridFigExit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(gcf);
% --------------------------------------------------------------------
function FileExplain_Callback(hObject, eventdata, handles)
% hObject handle to FileExplain (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -