why I'm getting error " Array indices must be positive integers or logical values."

2 ビュー (過去 30 日間)
Fabian Lopez
Fabian Lopez 2021 年 2 月 10 日
回答済み: the cyclist 2021 年 2 月 10 日
%% Atmospheric Pressure
%P=Patm(1+((B*Z)/Tatm))^(g/(R*B))
R = 287;
g = 9.81; % m/s^2
B = .0065; % K/m
Patm = 101325; % Pa
Tatm = 288.15; % K
P = 88200; % Pa
%Creating equation for atmospheric presure at height Z for solution
func_atm_pressure=@(Z) P-Patm(1+((B*Z)/Tatm))^(g/(R*B));
%Solving for Z using fzero function
fzero(func_atm_pressure, 1000)

回答 (1 件)

the cyclist
the cyclist 2021 年 2 月 10 日
You need the multiplication sign after Patm:
func_atm_pressure=@(Z) P-Patm*(1+((B*Z)/Tatm))^(g/(R*B));

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by