Clear Filters
Clear Filters

New to matlab, trying to understand basic functions still

2 views (last 30 days)
Hello! I am new to matlab and I am working with some data, however, I am trying to understand what it means with the following (hopefully this makes sense):
x= D0a(:,1); nf=length(x);
y=(1:9)'; ns= length(y);
D0a is the element.

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 2 Nov 2023
Edited: Sulaymon Eshkabilov on 2 Nov 2023
The meaning of these entries are:
x= D0a(:,1); % The existing variable D0a's column 1 is assigned to a new variable called x
nf=length(x); % Counting the length of x (vector)
y=(1:9)'; % Creating y vector, transposing 1 to 9 (row vector) into 1:9 column vector
ns= length(y); % Counting the length of y (vector)
% to get help on any of MATLAB functions use: help
help length
help transpose
% Advice: study MATLAB Onramp

More Answers (2)

the cyclist
the cyclist on 2 Nov 2023
Assuming that D0a is a matrix, then
  • x is the 1st column of that matrix. (x is a column vector.)
  • nf is the number of elements in that vector x.
  • y is the vector [1 2 3 4 5 6 7 8 9], but then transposed to be a column vector, rather than a row vector.
  • ns is the number of elements in that vector y.
You are right that these are very basic questions. I strongly suggest you invest a couple hours in viewing the free MATLAB Onramp online tutorial.

John D'Errico
John D'Errico on 2 Nov 2023
If you are this new to MATLAB, then you seriously need to spend some tie reading the tutorials available.
The MATLAB Onramp is a good place to start. But there are also many other things you can read. Why not read the manual? Yes, I know, you don't need no steenkin' mauals. Spend a couple of hours. It will pay dividends.

Categories

Find more on MATLAB 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!