Let me just start by sharing the fixed code. (I also fixed a bug in the first for loop.)
for i=1:numel(ubq.Model.Atom)
if ubq.Model.Atom(i).AtomName == "CA"
b=[ubq.Model.Atom(i).X,ubq.Model.Atom(i).Y,ubq.Model.Atom(i).Z];
Text in single quotes is a character vector. In this case, == will compare the two characters in CA one by one and error as you see if AtomName does not have exactly two characters. Also note that the result of this comparison will be a two-element logical vector with the result for each character. For example:
This behavior was introduced in the very first version of MATLAB. Character arrays are treated much like numeric arrays. And that was consistent with the focus of MATLAB on arrays in the early days. I should also mention another option here. You could instead compare two character vectors using the strcmp function:
Now, this confused a lot of people. And wasn't very convenient for the kinds of text processing we do today. So a few years ago, MATLAB introduce a new way to store text: strings. That's what "CA" is. And strings behave more like what you would expect when processing text, including == meaning that you compare the entire contents of the string and return a single true or false indicating whether the text matches. You can find more information in MATLAB's documentation here. Lastly, let me show you how I'd write this to avoid the for loop entirely and present all the results in a single matrix
isCA = ({ubq.Model.Atom.AtomName} == "CA");
caAtoms = ubq.Model.Atom(isCA);
coordinates = [caAtoms.X; caAtoms.Y; caAtoms.Z]'
coordinates =
26.2660 25.4130 2.8420
26.8500 29.0210 3.8980
26.2350 30.0580 7.4970
26.7720 33.4360 9.1970
28.6050 33.9650 12.5030
27.6910 37.3150 14.1430
30.2250 38.6430 16.6620
29.6070 41.1800 19.4670
31.4220 43.9400 17.5530
28.9780 43.9600 14.6780