vector in cell in matlab

To create a vector inside a cell array in MATLAB, you can follow these steps:

  1. Create a cell array using curly braces {}.
  2. Inside the cell array, assign a vector or an array of values using square brackets [].

Here's an example of how you can do it:

main.m
% Create a cell array
myCellArray = {};

% Create a vector
myVector = [1, 2, 3, 4, 5];

% Assign the vector to the cell array
myCellArray{1} = myVector;

% Access the vector inside the cell array
result = myCellArray{1};
disp(result);
235 chars
13 lines

Output:

main.m
   1   2   3   4   5
21 chars
2 lines

In this example, we created a cell array myCellArray using curly braces {}. Then, we created a vector myVector using square brackets []. Finally, we assigned the vector to the first element of the cell array myCellArray{1}. The result is then accessed and displayed using disp() function.

related categories

gistlibby LogSnag