What is wrong with my code for obtaining 3D maps?
4 次查看(过去 30 天)
显示 更早的评论
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
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
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!