cara membuat grafik 3D Plots Surf, Mesh, dan Contour menggunakan matlab
Fungsi-fungsi
dari visualisasi data 3D.
SURF atau grafik permukaan, digunakan untuk memvisualisaikaan data dalam bentuk permukaan 3D dengan pewarnaan berdaarkan bobot nilai gridnya.
MESH, digunakan memvisualisasikan data dalam bentuk tiga dimensi. mesh sering disebut sebagai grafik jala yang memiliki empat titik data terdekat dalam ruang 3D.
CONTOUR, digunakan untuk membuat gariskontur dibuat dengan teknik inperpolasi titik-titik terdekat.
sebelum memulai sebaiknya membuat langkah awal seperti menampilkan axes,panel (pict typo, push button (surf,mesh,contour),stastic text, dan pop-up menu (peaks,membrane,sinc).
1. maka tampilan awal akan seperti gambar di bawah ini.
kemudian masukan coding sebagai berikut :
% --- Executes just before yana is made visible.
function yana_OpeningFcn(hObject, eventdata, handles, varargin)
handles.peaks = peaks (35);
handles.membrane = membrane;
[x, y] = meshgrid (-8:0.5:8);
r = sqrt(x.^2 + y.^2) + eps;
sinc = sin(r)./r;
handles.sinc = sinc;
handles.current_data = handles.peaks;
surf(handles.current_data);
handles.peaks = peaks (35);
handles.membrane = membrane;
[x, y] = meshgrid(-8:0.5:8);
r = sqrt(x.^2 + y.^2) + eps;
sinc = sin (r)./r;
handles.sinc = sinc;
handles.current_data = handles.peaks;
surf(handles.current_data);
% Choose default command line output for yana
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes yana wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = yana_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
val = get(hObject, 'Value');
str = get(hObject, 'String');
switch str{val}
case 'peaks'
handles.current_data = handles.peaks;
case 'membrane'
handles.current_data = handles.membrane;
case 'sinc'
handles.current_data = handles.sinc;
end
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
surf(handles.current_data);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mesh(handles.current_data);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
contour(handles.current_data);
2. setelah coding di buat maka klik run dan akan muncul hasil seperti ini :
hasil dari PEAKS
peaks-suft
peaks-mesh
peaks-contour
hasil dari MEMBRANE
membrane-surf
membrane-mesh
membrane-contour
hasil dari SINC
sinc-surf
sinc-mesh
sinc-contour
sekian untuk pembuatan grafik menggunakan matlab.
Komentar
Posting Komentar