Repetetion of x,z,b,c value simulataneous
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dear sir/madam,
I am unable to repeat the x,z,c,b value simultaneously. I have attached the final plot to be obtained.
Please look into the problem
Thank you
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/845890/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/845895/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/845900/image.png)
%% to find the cloud points of xzbc
%% to calculate the number of grating on primary surface
clc
clear all
R=30; %% radius of curvature
W=0.0125; %% width of grating
r=10; %% radius of workpiece
th_1=(asin(W/R)); %% angle at which blazed grating existd
degr=(180*th_1)/pi; %% conversion into degree
th_2=2*(asin(r/R)); %% angle at which primary profile exists
degr_2=(180*th_2)/pi; %% conversion into degree
n=round(degr_2/degr); %% number of grating
%% to generate the primary profile
for i=1:n
th (i)= ((i*th_1)-((th_2)/2));
deg (i)=(180*th (i))/pi;
x(i)= -(R*cos(th (i)));
z(i)= (R*sin(th (i)));
end
X1=x;
Z1=z;
figure (1)
% plot(X1,Z1); hold on
%% to calculate the B-axis Coordinate
th_3=0.144; %% blazed grating angle
degr_3=8.25;
for i=1:n
th (i)= ((i*th_1)-((th_2)/2));
b(i)= th (i)+th_3;
deg_2(i)= (180*b(i))/pi;
end
B1=b;
% figure (1)
% plot(B1); hold on
% figure (2)
% plot3(X1,Z1,B1);
% x2=x;
% z2=z;
%% Cutting action i.e. XZBC Calculation
th_4=0.017; %% radial data resolution in radian
m= round(th_2/th_4)-1; %%
for j=1:m
c(j)=((j*th_4-(th_2/2))*(180/pi)); %% to extract C-axis coordinate
end
c2=c;
b2=b;
x2=x;
z2=z;
%% Non-cutting action i.e. XZBC Calculation
p=round(((2*pi)-th_2)/(th_4));
for i=1:n-1
for k=1:p
X(k)= x(i)+((k*(x(i+1)-x(i))/p));
Z(k)= z(i)+(k*(z(i+1)-z(i))/p);
C(k)=((m*th_4-(th_2/2)+k*th_4)*(180/pi));
B(k)= b(i)+(k*(b(i+1)-b(i))/p);
end
end
newx= X1+X;
newz= Z1+x;
plot(newx,newz);
% xrep= repelem(X,3);
% zrep= repelem(Z,3);
% crep= repelem(C,3);
% brep= repelem(B,3);
% plot(xrep,zrep);
% C= [0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360];
% X= [30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30];
% Z= [0.984 0.985 0.986 0.987 0.988 0.989 0.99 0.991 0.992 0.993 0.994 0.995 0.996 0.997 0.998 0.999 1.000 1.000 1.000 1.000 1.000 1.001 1.002 1.003 1.004 1.005 1.006 1.007 1.008 1.009 1.01 1.011 1.012 1.013 1.014 1.015 1.016];
% B=[0.139 0.139 0.139 0.139 0.139 0.139 0.139 0.139 0.139 0.139 0.139 0.139 0.139 0.139 0.139 0.139 0.14 0.14 0.14 0.14 0.14 0.141 0.141 0.141 0.141 0.141 0.141 0.141 0.141 0.141 0.141 0.141 0.141 0.141 0.141 0.141 0.141];
%
% plot3(Z,C,B);
4 comentarios
Walter Roberson
el 29 de Dic. de 2021
You did not attach the file.
When I search on that file name, I find a number of different science papers.
Respuestas (1)
Walter Roberson
el 30 de Dic. de 2021
%% to find the cloud points of xzbc
%% to calculate the number of grating on primary surface
clc
clear all
R=30; %% radius of curvature
W=0.0125; %% width of grating
r=10; %% radius of workpiece
th_1=(asin(W/R)); %% angle at which blazed grating existd
degr=(180*th_1)/pi; %% conversion into degree
th_2=2*(asin(r/R)); %% angle at which primary profile exists
degr_2=(180*th_2)/pi; %% conversion into degree
n=round(degr_2/degr); %% number of grating
%% to generate the primary profile
for i=1:n
th (i)= ((i*th_1)-((th_2)/2));
deg (i)=(180*th (i))/pi;
x(i)= -(R*cos(th (i)));
z(i)= (R*sin(th (i)));
end
X1=x;
Z1=z;
figure (1)
% plot(X1,Z1); hold on
%% to calculate the B-axis Coordinate
th_3=0.144; %% blazed grating angle
degr_3=8.25;
for i=1:n
th (i)= ((i*th_1)-((th_2)/2));
b(i)= th (i)+th_3;
deg_2(i)= (180*b(i))/pi;
end
B1=b;
% figure (1)
% plot(B1); hold on
% figure (2)
% plot3(X1,Z1,B1);
% x2=x;
% z2=z;
%% Cutting action i.e. XZBC Calculation
th_4=0.017; %% radial data resolution in radian
m= round(th_2/th_4)-1; %%
for j=1:m
c(j)=((j*th_4-(th_2/2))*(180/pi)); %% to extract C-axis coordinate
end
c2=c;
b2=b;
x2=x;
z2=z;
%% Non-cutting action i.e. XZBC Calculation
p=round(((2*pi)-th_2)/(th_4));
for i=1:n-1
for k=1:p
X(p,k)= x(i)+((k*(x(i+1)-x(i))/p));
Z(p,k)= z(i)+(k*(z(i+1)-z(i))/p);
C(p,k)=((m*th_4-(th_2/2)+k*th_4)*(180/pi));
B(p,k)= b(i)+(k*(b(i+1)-b(i))/p);
end
end
subplot(4,1,1); surf(X, 'edgecolor', 'none'); title('X'); xlabel('k'); ylabel('i');
subplot(4,1,2); surf(Z, 'edgecolor', 'none'); title('Z'); xlabel('k'); ylabel('i');
subplot(4,1,3); surf(C, 'edgecolor', 'none'); title('C'); xlabel('k'); ylabel('i');
subplot(4,1,4); surf(B, 'edgecolor', 'none'); title('B'); xlabel('k'); ylabel('i');
whos
%you have a problem. X was just created as 330 x 330, but X1 is 1 x 1361.
%Even if we had only created X as 330 x 1 or 1 x 330 then we would have a
%problem.
newx= X1+X;
newz= Z1+x;
plot(newx, newz)
Maybe you mean X1+x like you have for Z1 ? Speaking of which, wouldn't Z1 + z make more sense for z values?
Anyhow, it is not obvious to me what out of what you calculated (X, Z, B, C) that you want to plot against what. And if you look at the shapes in those variables... are you sure that is what you are expecting with increasing i values?
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!