I've been stuck for weeks on a code that I have been generating for image processing. And made an example of what I need. I have this code: (BTW Im new to this matlab world)(adsbygoogle = window.adsbygoogle || []).push({});

A = [2, 5, 6; 3,6,7];

B = [5, 3, 1; 7,3,2];

for i=1:3

v = genvarname('C', who);

eval([v '= A-B'])

end

The part above ^^^^ gives me this:

C =

-3 2 5

-4 3 5

C1 =

-3 2 5

-4 3 5

C2 =

-3 2 5

-4 3 5

This is the part im having problem explaining.

I want to do something like this:

for n=1:3

F{n} = C{n}(2,1) + B(2,1)

end

But it tells me:

Cell contents reference from a non-cell array object.

I really dont know what to do. Can someone help me?

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab Problem with loops and genvarname

**Physics Forums | Science Articles, Homework Help, Discussion**