matrix full of zeros

2 ビュー (過去 30 日間)
Jessica Larry
Jessica Larry 2020 年 4 月 28 日
コメント済み: Ameer Hamza 2020 年 4 月 28 日
load('air.txt')
Air.temp = air(:,1);
Air.press = air(:,2);
Air_R = 0.287;
for k = 1:length(air)
Air(k).vol = (Air_R*Air(k).temp)/Air(k).press;
end
I am using the ideal gas law to solve for volume and I made a structure with all the information needed (pressure, temperature). I am trying to make a subfield in that structure called vol (for volume) but the matrix that comes out as a result when I look at Air.vol is a maxtrix full of zeros and then colum 35 has all the values I need. Is there a way to minimize this so there's only one colum with the values I need?

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 28 日
Use element-wise division
Air(k).vol = (Air_R*Air(k).temp)./Air(k).press;
%^ add dot here
  2 件のコメント
Jessica Larry
Jessica Larry 2020 年 4 月 28 日
Thanks you so much!
Ameer Hamza
Ameer Hamza 2020 年 4 月 28 日
Glad to be of help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by