Matrix with different order

1 次查看(过去 30 天)
Chetan Fadnis
Chetan Fadnis 2021-7-14
I want to use 10*1 matrix for N=10, now as I keep changing N =20,30,40,50, matrix order must also change like, 20*1,30*1,40*1,50*1... using rand(N,1) I can produce required array. My problem is I am using a for loop, N=10:10:50 And I want to use matrix of order N*1 defined Outside of this loop. Kindly help how to write the code.
  6 个评论
DGM
DGM 2021-7-14
编辑:DGM 2021-7-14
If your vector needs to be of variable length, based on the state of the loop, why can't you do it in the loop? You'd need to precalculate all the vectors otherwise. You could store them in a cell array, but why set up one loop to build an array of variable length vectors just to avoid generating them at the time of use in another loop?
Depending on your needs, you may be able to calculate one oversize vector and then generate the shorter vectors by sampling from it, but I don't see how that's going to be easier than just doing it in the loop.
Chetan Fadnis
Chetan Fadnis 2021-7-14
Thank you Sir, I will be trying it.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by