8 views (last 30 days)

Hi all

I got a piece of my code that is causing function nesting error and the root cause is that matlab is not understanding the end written in Matrix(end)

is not related to the loop or function end and has messed up

exactly where I haveTtot(end) , this end is confused

for fn=1:numel(files)

ff= xlsread(strcat(files{fn},'.xlsx'));

filename=files{fn};

t = ff(:,1);

resol=t(2)-t(1);

motion6t=ff;

mulnames=readcell('Ms.xlsx')

mask = strcmp(filename, mulnames(:,1));

multip = cell2mat(mulnames(mask, 2));

resol=t(2)-t(1)

if fn==1

motiontot=[];

for m=1:multip

if m==1

Ttot=t.';

else

Ttot= [Ttot,t.'+Ttot(end)+resol];

end

end

else

for m=1:multip

Ttot= [Ttot,t.'+Ttot(end)+resol];

end

end

for m=1:multip

motiontot=[motiontot;motion6t];

end

end

Walter Roberson
on 13 May 2020

mTtot=[]

size(mTtot)

mTtot =

[]

ans =

0 0

with it being empty, end as an index would be 0. mTtot(end) would be mTtot(0) which is not permitted.

mTtot= [mTtot ,t.'+mTtot(end)+resol];

Perhaps you are wanting mTtot(end) to be empty instead of an error when mTtot is empty. But if that were the case, then you would have the situation

mTtot = [[], t.'+[]+resol]

and anything + [] is [], so you would be dealing with

mTtot = [[], []]

which would leave mTtot empy, but I suspect you are trying to append to it in that statement,.

Opportunities for recent engineering grads.

Apply TodayFind the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 11 Comments

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846515

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846515

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846520

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846520

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846526

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846526

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846530

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846530

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846533

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846533

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846548

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846548

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846583

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846583

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846590

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846590

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846597

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846597

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846673

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846673

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846761

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/525128-matlab-app-designer-confuses-the-end-written-inside-matrix-index-with-the-end-for-if-and-for-loop#comment_846761

Sign in to comment.