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

4 ビュー (過去 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 Center および File ExchangeOrange についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by