How to create a matrix array with increments equation using vectorization?
23 次查看(过去 30 天)
显示 更早的评论
I am trying to create a matrices array after calculating the area and volume of a system with increment equations. Basically the area and volume are changing from 1 to 10 seconds with 1 second increments. Then I have to create a matrix array showing the time with increments row as first column and corresponding calculated area and volume as the second and third column of the matrix using vectorization.
s=0.1;
y=pi;
x=1:1:5;
area=s.*sqrt(y.*x);
vol=s.*y*sqrt(y.*x);
B=[x area vol];
So basically my matrices should be 5x3. But I am confused as to how I can put the rows as increments, I am getting 1x15 matrices.
0 个评论
采纳的回答
KSSV
2022-2-14
s=0.1;
y=pi;
x=[1:1:5]'; % transpose this
area=s.*sqrt(y.*x);
vol=s.*y*sqrt(y.*x);
B=[x area vol];
size(B)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!