I need to make a table that is 7x5 with these variables:
mass=[50:5:80]; (this is the 7 columns) and height=[1.5:.1:1.9]; (these are the 5 rows).
I have this equation:
>> BMI=[mass]./[height].^2
And it says "Matrix Dimensions Must Agree". I thought since I have the periods in front of the "/" and the "^" that I wouldn't have that problem, so I don't know why it won't give me a table?

 채택된 답변

jgg
jgg 2016년 2월 19일

0 개 추천

You've only created two vectors, not matrices. You're basically trying to divide a 1-by-5 by a 1-by-7 which doesnt work. What you probably want is:
[M,H] = meshgrid(mass,height);
BMI = M./(H.^2);

댓글 수: 1

That's exactly what I wanted, thank you. Only one more question, how can I put the masses on the top and the heights on the side so you can match up your height and weight?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

태그

질문:

2016년 2월 19일

편집:

2016년 2월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by