how to fill a matrix with different size vectors

8 次查看(过去 30 天)
I have a for cycle. each time the output is of different lenght.
I would like to put each output in the rows of a unique matrix and in the same time to save the vectors with consecutive names, like output1, output2, outpu3....
for i=1:4:size(index,2)
step=degree(index(i):index(i+3))'
end
  1 个评论
madhan ravi
madhan ravi 2020-11-6
Don't name a variable step and degree because there are inbuilt MATLAB functions.
help step
STEP Step response of dynamic systems. [Y,T] = STEP(SYS) computes the step response Y of the dynamic system SYS. The time vector T is expressed in the time units of SYS and the time step and final time are chosen automatically. For multi-input systems, independent step commands are applied to each input channel. If SYS has NY outputs and NU inputs, Y is an array of size [LENGTH(T) NY NU] where Y(:,:,j) contains the step response of the j-th input channel. For state-space models, [Y,T,X] = STEP(SYS) also returns the state trajectory X, an array of size [LENGTH(T) NX NU] for a system with NX states and NU inputs. For identified models (see IDMODEL), [Y,T,X,YSD] = STEP(SYS) also computes the standard deviation YSD of the response Y (YSD is empty if SYS does not contain parameter covariance information). [Y,...] = STEP(SYS,TFINAL) simulates the step response from t=0 to the final time t=TFINAL (expressed in the time units of SYS). For discrete- time models with unspecified sample time, TFINAL is interpreted as the number of sampling periods. [Y,...] = STEP(SYS,T) specifies the time vector T for simulation (in the time units of SYS). For discrete-time models, T should be of the form 0:Ts:Tf where Ts is the sample time. For continuous-time models, T should be of the form 0:dt:Tf where dt is the sampling period for the discrete approximation of SYS. [Y,...] = STEP(SYS,...,OPTIONS) specifies additional options such as the step amplitude or input offset. Use stepDataOptions to create the option set OPTIONS. When called without output arguments, STEP(SYS,...) plots the step response of SYS and is equivalent to STEPPLOT(SYS,...). See STEPPLOT for additional graphical options for step response plots. See also STEPPLOT, stepDataOptions, IMPULSE, INITIAL, LSIM, LTIVIEW, DYNAMICSYSTEM, IDLTI. Documentation for step doc control/step Other functions named step DynamicSystem/step iddata/step system/step
help degree
--- help for graph/degree --- DEGREE Degree of nodes in a graph D = DEGREE(G) returns the degree of each node of G, in a column vector. D = DEGREE(G, NODEIDS) returns the degree of the nodes specified by NODEIDS. NODEIDS can be a numeric array of node IDs or an array of node names. D has the same dimensions as NODEIDS. Example: % Create a graph, and then compute the degree of its nodes. s = [1 1 1 4 4 6 6 6]; t = [2 3 4 5 6 7 8 9]; G = graph(s,t); d = degree(G) Example: % Create a graph, and then compute the degree of a subset of nodes. s = {'a' 'a' 'a' 'd' 'd' 'f' 'f' 'f'}; t = {'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i'}; G = graph(s,t) nodeIDs = {'a' 'c' 'e'}'; d = degree(G,nodeIDs) See also GRAPH, NEIGHBORS, DIGRAPH/INDEGREE, DIGRAPH/OUTDEGREE Documentation for graph/degree doc graph.degree Other functions named degree laurpoly/degree

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2020-11-6
编辑:KSSV 2020-11-6
Read about Cells. You can save them into cell.
N = 10 ;
iwant = cell(N,1) ;
for i = 1:N
iwant{i} = rand(randperm(10,1),1) ;
end
  2 个评论
matteo bottoni
matteo bottoni 2020-11-6
编辑:matteo bottoni 2020-11-6
Honestly I am not understanding. Can you help me a little bit more? How can i mix cell with my cycle?
KSSV
KSSV 2020-11-6
step = cell([],1) ;
count = 0;
for i=1:4:size(index,2)
count = count+1 ;
step{count}=degree(index(i):index(i+3))'
end
step

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genomics and Next Generation Sequencing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by