Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

indexing must appear last in an index expression

139 views
Skip to first unread message

Erika

unread,
Feb 17, 2015, 12:53:57 AM2/17/15
to
I'm not sure why I get the "indexing must appear last in an index expression" error. I know it is common, but as a new user, I cannot figure out where the curly braces need to be.

Thanks!

clc
%load as vectors
for i = 1:14;
ds = dataset(chrom, pos, x3D7_A10P, x3D7_812, x3D7_712, x3D7_5391, Dd2_TM1, Dd2_TM2, Dd2_PQR);
ds_chr(i)= ds(ds.chrom==(i),:);
meancov_A10P_chr(i) = mean(double(ds_chr(i)(:,3:3)),1);
meancov_812_chr(i) = mean(double(ds_chr(i)(:,4:4)),1);
meancov_712_chr(i) = mean(double(ds_chr(i)(:,5:5)),1);
meancov_5391_chr(i) = mean(double(ds_chr(i)(:,6:6)),1);
meancov_TM1_chr(i) = mean(double(ds_chr(i)(:,7:7)),1);
meancov_TM2_chr(i) = mean(double(ds_chr(i)(:,8:8)),1);
meancov_PQR_chr(i) = mean(double(ds_chr(i)(:,9:9)),1);

norm_A10P_chr(i) = (double(ds_chr(i)(:,3:3)))/meancov_A10P_chr(i);
norm_812_chr(i) = (double(ds_chr(i)(:,4:4)))/meancov_812_chr(i);
norm_712_chr(i) = (double(ds_chr(i)(:,5:5)))/meancov_712_chr(i);
norm_5391_chr(i) = (double(ds_chr(i)(:,6:6)))/meancov_5391_chr(i);
norm_TM1_chr(i) = (double(ds_chr(i)(:,7:7)))/meancov_TM1_chr(i);
norm_TM2_chr(i) = (double(ds_chr(i)(:,8:8)))/meancov_TM2_chr(i);
norm_PQR_chr(i) = (double(ds_chr(i)(:,9:9)))/meancov_PQR_chr(i);

T=table(norm_A10P_chr(i), norm_812_chr(i), norm_712_chr(i), norm_5391_chr(i));
A=table2array(T);
calibrate=nanmean(A,2);
cal_A10P_chr(i)=norm_A10P_chr(i)./calibrate;
cal_812_chr(i)=norm_812_chr(i)./calibrate;
cal_712_chr(i)=norm_712_chr(i)./calibrate;
cal_5391_chr(i)=norm_5391_chr(i)./calibrate;
cal_TM1_chr(i)=norm_TM1_chr(i)./calibrate;
cal_TM2_chr(i)=norm_TM2_chr(i)./calibrate;
cal_PQR_chr(i)=norm_PQR_chr(i)./calibrate;

figure
pos_chr(i)=(double(ds_chr(i)(:,2:2)));
hold on;
h(1) = subplot(7,2,1);
scatter(pos_chr(i), cal_A10P_chr(i), 'filled', 'blue');
scatter(pos_chr(i), cal_812_chr(i), 'filled', 'green');
scatter(pos_chr(i), cal_712_chr(i), 'filled', 'red');
scatter(pos_chr(i), cal_5391_chr(i), 'filled', 'cyan');
scatter(pos_chr(i), cal_TM1_chr(i), 'filled', 'yellow');
scatter(pos_chr(i), cal_TM2_chr(i), 'filled', 'magenta');
scatter(pos_chr(i), cal_PQR_chr(i), 'filled', 'black');

legend('A10P', '812', '712', '5391', 'TM1', 'TM2', 'PQR');
hold off;
end

dpb

unread,
Feb 17, 2015, 9:25:23 AM2/17/15
to
On 02/16/2015 11:53 PM, Erika wrote:
> I'm not sure why I get the "indexing must appear last in an index
> expression" error. I know it is common, but as a new user, I cannot
> figure out where the curly braces need to be.
>
...

As the error message says, "last"

LHS=cell{idxCell}(idxArrayExpression);

Use the curlies to dereference the cell content then the paren's to
select from that array.

NB: You canNOT use a multiple selection index expression in the cell
index; _ONLY_ a single cell can be accessed at a time

--


dpb

unread,
Feb 17, 2015, 10:30:38 AM2/17/15
to
On 02/17/2015 8:25 AM, dpb wrote:
> On 02/16/2015 11:53 PM, Erika wrote:
>> I'm not sure why I get the "indexing must appear last in an index
>> expression" error. I know it is common, but as a new user, I cannot
>> figure out where the curly braces need to be.
>>
> ...
>
> As the error message says, "last"
>
> Use the curlies to dereference the cell content then the paren's to
> select from that array.
>
> NB: You canNOT use a multiple selection index expression in the cell
> index; _ONLY_ a single cell can be accessed at a time

ADDENDUM:

In expression

LHS=cell{idxCell}(idxArrayExpression);

"cell" is the cell array name, _NOT_ the ML function CELL().

--

0 new messages