Not getting curve in my graph

7 次查看(过去 30 天)
When I plot K1 and K2 seperately, I get two graphs for the values so I know the numbers are not static. However, when I try to use them in my theta equation to then get a curve of the theta value, it just plots a straight line. Any ideas?
n=100;
s=zeros(n,1);
F=zeros(n,1);
W=zeros(n,1);
K1=zeros(n,1);
K2=zeros(n,1);
ybar= linspace(0,0.4,n);
Sxx = -(-log((ybar).^2)-1-(-log((-2).^2+(ybar).^2-(ybar.^2./((-2).^2+ybar.^2)))));
Sxy = (atan(-2./(ybar)+(((ybar)+(-2))./((-2)^2+(ybar).^2))));
for i=1:n
s(i)=cos(((2*i-1)*pi())/(2*(2*n+1)))^2;
W(i)=s(i)*((2*pi())/(2*n+1));
F(i)=(1-s(i)^2)*(0.2945-.3912*s(i)^2+0.7685*s(i)^4-0.9942*s(i)^6+0.5094*s(i)^8);
K1(i)=(1/(2*pi()^2))*W(i)*Sxx(n)*((1+F(i))/sqrt(s(i)*(1+s(i))));
end
for i=1:n
s(i)=cos(((2*i-1)*pi())/(2*(2*n+1)))^2;
W(i)=s(i)*((2*pi())/(2*n+1));
F(i)=(1-s(i)^2)*(0.2945-.3912*s(i)^2+0.7685*s(i)^4-0.9942*s(i)^6+0.5094*s(i)^8);
K2(i)=(1/(2*pi()^2))*W(i)*Sxy(n)*((1+F(i))/sqrt(s(i)*(1+s(i))));
end
for i=1:n
theta=2*atan(((1/4)*K1(n)/K2(n)))+((1/4)*((((K1(n)/K2(n)))^(.5))+9)^(.5));
end
hold on
figure(1)
plot(ybar,theta,'.');
xlabel('y/L');
ylabel('theta [deg]')
hold off

采纳的回答

Star Strider
Star Strider 2022-8-6
Any ideas?
Yes.
Subscript ‘theta’ and all the argument vectors using the loop index ‘i’ rather than ‘n’.
n=100;
s=zeros(n,1);
F=zeros(n,1);
W=zeros(n,1);
K1=zeros(n,1);
K2=zeros(n,1);
ybar= linspace(0,0.4,n);
Sxx = -(-log((ybar).^2)-1-(-log((-2).^2+(ybar).^2-(ybar.^2./((-2).^2+ybar.^2)))));
Sxy = (atan(-2./(ybar)+(((ybar)+(-2))./((-2)^2+(ybar).^2))));
for i=1:n
s(i)=cos(((2*i-1)*pi())/(2*(2*n+1)))^2;
W(i)=s(i)*((2*pi())/(2*n+1));
F(i)=(1-s(i)^2)*(0.2945-.3912*s(i)^2+0.7685*s(i)^4-0.9942*s(i)^6+0.5094*s(i)^8);
K1(i)=(1/(2*pi()^2))*W(i)*Sxx(n)*((1+F(i))/sqrt(s(i)*(1+s(i))));
end
for i=1:n
s(i)=cos(((2*i-1)*pi())/(2*(2*n+1)))^2;
W(i)=s(i)*((2*pi())/(2*n+1));
F(i)=(1-s(i)^2)*(0.2945-.3912*s(i)^2+0.7685*s(i)^4-0.9942*s(i)^6+0.5094*s(i)^8);
K2(i)=(1/(2*pi()^2))*W(i)*Sxy(n)*((1+F(i))/sqrt(s(i)*(1+s(i))));
end
for i=1:n
theta(i)=2*atan(((1/4)*K1(i)/K2(n)))+((1/4)*((((K1(i)/K2(i)))^(.5))+9)^(.5));
end
hold on
figure(1)
plot(ybar,theta,'.');
xlabel('y/L');
ylabel('theta [deg]')
hold off
Is that the desired result?
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by