how to fill a matrix with different size vectors

8 views (last 30 days)
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 Comment
madhan ravi
madhan ravi on 6 Nov 2020
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

Sign in to comment.

Accepted Answer

KSSV
KSSV on 6 Nov 2020
Edited: KSSV on 6 Nov 2020
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 Comments
matteo bottoni
matteo bottoni on 6 Nov 2020
Edited: matteo bottoni on 6 Nov 2020
Honestly I am not understanding. Can you help me a little bit more? How can i mix cell with my cycle?
KSSV
KSSV on 6 Nov 2020
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

Sign in to comment.

More Answers (0)

Categories

Find more on Genomics and Next Generation Sequencing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!