user3536870
user3536870

Reputation: 249

MATLAB reading a variable in workspace

In my workspace I have a variable named result which stores <100x1 cell>

In each one, so for example result{1,1} has the sample of data:

0.000   0.0080
0.020   0.0082
0.024   0.0048
0.031   0.0061
0.056   0.0100

What I want to be able to do is read into my variable result and then read all of the subsections such as result{1,1} and result{23,1} for example. I then want to be able to manipulate this data and eventually create a plot.

It would be important to be able to make a matrix (or something) for example of result{1,1} and then to manipulate column 1 and then plot column 1 against column 2. Is there something possible to enable me to do this?

Thanks in advance for any help/suggestions :)

Upvotes: 0

Views: 83

Answers (1)

NKN
NKN

Reputation: 6434

You question is not really clear. Do you want to perform something like this?

for ii=1:size(result,1)
    M = result{ii,1};
    M1 = M(:,1);
    M2 = M(:,2);
    plot(M1,M2,'o');hold on
end

Or as suggested by @Luis Mendo you can access each column directly:

for ii=1:size(result,1)
    M1 = result{ii,1}(:,1);
    M2 = result{ii,1}(:,2);
    plot(M1,M2,'o');hold on
end

if you want to access specific cells not all of them also you can do:

for ii=[1,23,44,50,98]
    M1 = result{ii,1}(:,1);
    M2 = result{ii,1}(:,2);
    plot(M1,M2,'o');hold on
end

Upvotes: 1

Related Questions