Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
storing all results in final matrix to save space in matlab when using for loop
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
coordinates for Points Pi(total 33 in #,11*3 matrix form) are known by combination of x-coord, y-coord, z-coord. Ray1 goes from known points A(x1,y1,z1) to P1(x2,y2,z2).It enters a region of interest at entry point(x3,y3,z3) and comes out through exit point(x4,y4,z4) such that entry and exit points are somewhere between A and P1.Transmission at entry point is known and I am trying to find out transmission at exit point because of attenuation.So, I reach to point,B in ray direction through incremental distance from A and find out transmission at B as I know transmission at entry point. Then I find out transmission at next point C as I know transmission at B. This way I finally find out transmission at exit point.Since I have 33 Pi points (in 3 rows and 11 columns), my final transmission matrix will be 3*11 size. I could the result if I create big matrix for intermediate steps like 'entry_point_coord,exit_point_coord, CT_number' etc. But I only want to store all my results in 'Final_Transmission' matrix. My matlab code is as follows. But I don't get a transmission matrix of required size and also did not get transmission values that I expect to get. Any help to resolve this issue will be appreciated.
A=[x1 y1 z1]
Transmission=1
% To create Pi points
x_coord=x1:increment:x2; %size 1*11
y_coord=y1:increment:y2; %size 1*3
z_coord=z; %it is constant
x_index=0;
y_index=0;
for i=1:3
y_index=y_index+1;
for j=1:11;
y_index=y_index+1;
Transmission=1
d=sqrt(sum(([x_coord(1,j),y_coord(1,i),z]-[x1,y1,z1]).^2));finding distance between A and Pi
entry_point_coordinate=[x1,y1,z1]+[x_coord(1,j)/d,y_coord(1,i)/d,z/d];
exit_point_coordinate=[x1,y1,z1]+[x_coord(1,j)/1.5*d,y_coord(1,i)/1.2*d,z/d];
x_coordinate_of_interest_point=entry_point_coordinate(1,1):increment:Exit_point_coordinate(1,1);
y_coordinate_of_interest_point=entry_point_coordinate(1,2):increment:Exit_point_coordinate(1,2);
z_coordinate_of_interest_pointt=entry_point_on_CT_data_for_ray(1,3):increment:Exit_point_coordinate(1,3);
for k=1:size(x_coordinate_of_interest_point,2);
spatial_coordinate_of_interest_point=[x_coordinate_of_interest_point(1,k) y_coordinate_of_interest_point(1,k) z_coordinate_of_interest_point(1,k)];
CT_number=interp3(....,spatial_coordinate_of_point);%I am fine with interp3 code inputs
attenuation=.2164*(1+CT_number/1000);% gives att coeff corresponding to CT_number
density=interp1(.....CT_number);%I am also fine with interp1 code inputs
Product=attenuation.*(0.1.*density);
New_Transmission_Factor=(Transmission_Factor).*(exp(-Product));
end
Final_Transmission(y_index,x_index)=New_Transmission_Factor;
end
end
0 Kommentare
Antworten (0)
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!