How can I employ 'for' loop for my specific problem?

1 view (last 30 days)
My problem is this:
I have a large sample data in the form of a column matrix (the data is around 10000 data points for each object). For each value of time 't' (another column matrix), I need the corresponding value of the data: for instance, for t(1,:), I need the correspondence y(1,:).
So how do I go about writing the "code of correspondence" between these two? It's like plotting only, in a way, except I need an executable function.
I am NOT seeking something like m = [t y] which gives me a matrix of the order a*b, where a is the number of rows and b is the number of columns.

Accepted Answer

Walter Roberson
Walter Roberson on 7 Jun 2015
Why not just
y.'
? The .' is to account for the fact that in t it is the first dimension that has the colon but in y it is the second dimension that has the colon.
  2 Comments
Prakriti Sardana
Prakriti Sardana on 7 Jun 2015
Edited: Prakriti Sardana on 7 Jun 2015
Oh, got it. To convert it to a column vector.
But, the more important question is, how can I assign each value of t to the corresponding value of y? :/
Walter Roberson
Walter Roberson on 7 Jun 2015
y = t.';
if you are doing the whole thing. Otherwise then general form
y(1,:) = t(:,1).'
which would generalize to (for example)
y(1:2, :) = t(:,1:2).'
or
y(1,:) = t(:,1);
a shortcut that would work only for a single column.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements 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!