I need to make a table out of a large matrix. Help?

1 次查看(过去 30 天)
I have a 280x3 matrix of values, and I need to make a table out of 10 points from them that fall between the rows that include -10 and 10, which are the 21st and 221st rows, respectively. My teacher gave us this hint:
Hint: Once you know which row has the -10 and 10 AA Temp degree you can use floor(linspace(r1,r2,N)) where r1 = the row with -10 and r2 = the row with 10. This will give you the row locations for N points which span the range are not quite equally spaced but close. Use these locations to get your AA Tire temperatures and the deflection values.
However, I am trying to use this command and it is not working. I'm getting really frustrated; all I'm trying to do is make a table. Please help?
M = xlsread('tire_lab');
T = floor(linspace(M(21,:),M(221,:),10))

回答(1 个)

Walter Roberson
Walter Roberson 2016-2-18
Either use a loop to linspace row by row, or substitute equivalent logic without linspace.
linspace(r1, r2, 10)
for row vectors r1 and r2 to be taken as pairs, can be calculated as
LS = (repmat(r1,10,1) + bsxfun(@times, (0:9).'/10, (r2-r1))).';
This will give you a length(r1) by 10 array ready to be further processed.
  2 个评论
Walter Roberson
Walter Roberson 2016-2-18
I would note, by the way, that the problem description is almost certainly talking about row numbers r1 and r2, rather than row contents
Aaron Zorzi
Aaron Zorzi 2016-2-18
When I try to do linspace(r1,r2,10) it tells me that the matrix dimensions don't agree and won't allow me to do anything else. What's wrong with it?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by