필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

plotting: making an array out of values made in a for loop?

조회 수: 1 (최근 30일)
Raphael Hatami
Raphael Hatami 2019년 10월 1일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello, I have variable theta and 100 points along its interval, and have found 100 corresponding points of phi. Now I need to plot phi vs theta, so I need to somehow call phi as an array of all those phi values. How do I do this? Thank you.
Here's my code for finding the 100 phi values (successful):
R = .5 %m
L = 1.25 %m
H = .25 %m
N = 100
theta = linspace(0, 4*pi, N);
for i = 1:N
fphi = @(phi) R*sin(theta(i)) + L*sin(phi) - H;
phi = fzero(fphi, phi)
end
here's my code for trying to plot phi vs theta, which is just making a blank graph as of yet:
%phi vs theta
plot(theta,phi);
title('Phi vs Theta')
ylabel('Phi [rad]')
xlabel('Theta [rad]')

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 10월 1일
편집: KALYAN ACHARJYA 2019년 10월 1일
R=.5; %m
L=1.25; %m
H=.25; %m
N=100;
phi=zeros(1,N);
theta=linspace(0, 4*pi, N);
for i=1:N
fphi=@(phi) R*sin(theta(i)) + L*sin(phi) - H;
phi(i)=fzero(fphi,phi(i));
end
%phi vs theta
plot(theta,phi);
title('Phi vs Theta')
ylabel('Phi [rad]')
xlabel('Theta [rad]')
678.png

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by