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))
2 个评论
回答(1 个)
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
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!