필터 지우기
필터 지우기

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 CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by