필터 지우기
필터 지우기

What is wrong with my code for obtaining 3D maps?

조회 수: 2 (최근 30일)
Adriana
Adriana 2022년 7월 7일
편집: Dyuman Joshi 2023년 9월 28일
Hi, I have this code of MATLAB for obtaining the number of counts from an Avalanche Photodiode detector (APD) with the NI-DAQ model USB 6211 and an external clock to obtain the counts and after it plots a 3D map with the X and Y position and the counts signal obtained from the APD. My problem is that with this code I am obtaining a distorted map. But I know my set up is ok and I am obtaining the results because I use another code to check the counts response. I would appreciate a lot your help. I attach the code and the image how it should be that I took with another detector and what I am obtaining.
numPointsX = 70;
numPointsY = 70;
xMin = 200;
xMax = 210;
yMin = 200;
yMax = 210;
xValues = linspace(xMin,xMax,numPointsX);
yValues = linspace(yMin,yMax,numPointsY);
observedCounts = zeros(numPointsX,numPointsY,1);
acq_time=0.02;
N = 1;
start(dq,"Continuous")
for k=1:numPointsX
current_x = xValues(k);
disp(sprintf("Line %d over %d",k,numPointsY))
for j=1:numPointsY
current_y = yValues(j);
PIdevice.MOV(['A','B'],[current_x current_y]);
dataIn= read(dq,seconds(acq_time));
n0 = max(dataIn.Dev1_ctr0)-min(dataIn.Dev1_ctr0);
dataCounts = n0/acq_time;
observedCounts(j,k,:) = dataCounts;
end
mapMax = squeeze(max(observedCounts,[],3));
f = figure(2);
imagesc(yValues,xValues,mapMax');
axis image;
end
stop(dq)
How it should be -->
How it is obtaining -->
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2022년 7월 7일
편집: Dyuman Joshi 2023년 9월 28일
X and Y limits along with the scale of the colorbar are not same for both figures.
Change the xlimits and ylimits and then compare.

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

답변 (1개)

Nipun
Nipun 2023년 9월 28일
Hi Adriana,
I understand that you want to change the output plot so that it resembles the given plot. I assume that the your code to generate the data points is correct and you need help with the formatting of the data points.
Perhaps two changes to your plot configuration should fix this issue: changing the xlim and ylim (refer to documentation here). In the reference figure, I can infer that y-axis ranges from 210 to 220, however the scale in the output plot is different. You may use the following code to change axis limits:
ylim([yMin, yMax]);
Additionally, consider changing the scale of the colorbar as well to match the reference image.
Hope this helps.
Regards,
Nipun

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by