Analyzing Atomic Force Microscope data using MATLAB

조회 수: 20 (최근 30일)
Alexander Link
Alexander Link 2019년 3월 7일
답변: Alexander Link 2019년 3월 10일
I am pretty new to MATLAB and only know some basic functions of the program. I have a 512x512 excel sheet that is height data from a section of surface the size of 20micometerX20micrometer. I am trying to input this data in to matlab and create a 2D and 3D plot of the data. I can input the data from excel and use the data to create a 'z' variable. What im struggling with is defining the x and y variable for the 3d plot and the x variable for the 2D plot. Please let me know if you believe you can help me!

채택된 답변

KSSV
KSSV 2019년 3월 7일
[num,txt,raw] = xlsread(myfile) ;
[ny,nx] = size(num) ;
L = 20 ; % micrometer
B = 20 ; % micrometer
x = linspace(0,L,nx) ;
y = linspace(0,B,ny) ;
[X,Y] = meshgrid(x,y) ;
figure(1)
pcolor(X,Y,num) ;
figure(2)
surf(X,Y,num) ;
  댓글 수: 3
Alexander Link
Alexander Link 2019년 3월 7일
and txt and raw?
KSSV
KSSV 2019년 3월 7일
I am reading data from excel file using xlsread. num gives numbers from excel data, txt gives you text data if any in excel file. raw gives you both text data nd number data as it exists in excel file. Read about xlsread.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Alexander Link
Alexander Link 2019년 3월 10일
Hey, I was wondering if you could help me on what im trying to do next with these graphs? I am trying to create an interactive interface that has a drop down menu with two options "2D Plot" and "3D Plot" and when one of these options is selected it launches the respected graph. I am finding the drop down menu to be kinda complicated for me so if having two push buttons is easier then that will also work. Here is what I have with my code so far but I keep getting a message that says "Error while evaluation UIControl Callback"
global Figure2D Figure3D
[num,txt,raw] = xlsread('Surface_Data.xlsx', 'PDA-PTFE_PFQNM_SA003ASCII3', 'A2:SR513');
[ny,nx] = size(num);
L = 20; %micrometer
B = 20; %micrometer
x = linspace(0,L,nx);
y = linspace(0,B,ny);
[X,Y] = meshgrid(x,y);
Figure2D = figure;
pcolor(X,Y,num);
Figure3D = figure;
surf(X,Y,num);
plotStyle2D = uicontrol(Figure2D,'Style','popupmenu');
plotStyle2D = uicontrol(Figure3D,'Style','popupmenu');
menuItems = [" Select Plot " "2D Plot" "3D Plot"];
dropDownPosition = [20 80 100 40];
plotStyle2D.String = menuItems;
plotStyle2D.Position = dropDownPosition;
plotStyle3D.String = menuItems;
plotStyle3D.Position = dropDownPosition;
plotStyle2D.Callback = @PlotType;
H
function PlotType(src,event)
val = src.Value;
str = src.String;
if(str{val} == '2D Plot')
figure(Figure2D);
elseif(str{val} == '3D Plot')
figure(Figure3D);
end
end

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by