finding an array of roots?

6 ビュー (過去 30 日間)
Raphael Hatami
Raphael Hatami 2019 年 10 月 1 日
回答済み: Raphael Hatami 2019 年 10 月 1 日
Hello, I'm trying to find the root of f with respect to phi, given multiple values of theta. However, when doing this, it calculates phi to be a single value, though it should be mutiple values given that theta is mutiple values. Below is my code, can anybody see what I'm doing wrong? Thank you
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

回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 10 月 1 日
編集済み: KALYAN ACHARJYA 2019 年 10 月 1 日
Is this?
R=.5; %m
L=1.25; %m
H=.25; %m
N=100
phi=0;
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
Or
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

Raphael Hatami
Raphael Hatami 2019 年 10 月 1 日
Kalyan,
thanks for taking the time to do this. I actually realized everything was already working properly and I just was reading the command window properly
Thanks anyhow,
Raphael

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by