draw isodosecurve with contour code in matlab

조회 수: 3 (최근 30일)
zahra khodakarami
zahra khodakarami 2022년 1월 13일
답변: Suraj Kumar 2025년 3월 4일
HI
I want to draw isodosecurve for my code that I write for you down with contour code. But I don not know how can I use contour command in my code to show me isodose curve.
My email: zahrakhodakarami2222@gmail.com
thanks for payattention
it is my code:
fid=fopen('out-put-ASI-Dose.bin','r');
a=zeros(201,201,201);
for i=1:201
a(i,:,:)=fread(fid,[201 201],'float');
end
b=a(:,:,101);
imshow(b,[]);
c=b(:,1,:)
;

답변 (1개)

Suraj Kumar
Suraj Kumar 2025년 3월 4일
To draw isodose curves using the contour function in MATLAB, you can follow these steps and refer to the attached code snippets. The contour function is used to create contour plots, which are useful for visualizing 3D data in 2D by representing lines of constant values.
1. You can read the binary file into a 3D array a, and then extract a 2D slice b at z=101.
fid = fopen('out-put-ASI-Dose.bin', 'r');
a = zeros(201, 201, 201);
for i = 1:201
a(i, :, :) = fread(fid, [201 201], 'float');
end
fclose(fid);
b = a(:, :, 101);
2. You can use imshow to visualize the 2D slice as an image.
imshow(b, []);
3. The contour function is used to plot isodose curves from the 2D data slice. You can specify the number of contour levels you want or provide specific levels by replacing contourLevels with an array of values.Additionally, you can add a color bar to understand the correspondence between the contour levels and the actual dose values.
figure;
contourLevels = 10;
contour(b, contourLevels);
colorbar;
title('Isodose Curves');
xlabel('X-axis');
ylabel('Y-axis');
Happy coding!

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by