How to avoid decreasing in length of file

I have been doing some manipulation in the for loop. I have constantly found that the calculation only works for some of the length of variables I assigned i.e. if jj = length(tcal) where tcal is 26, in the out put of results I usually find jj=1 or 2. what will be the possible reason and how can I avoid it . I can give you the whole script if needed.
Thanks for your help. It giving me hard time...

4 Comments

If tcal is 26 (a scalar) then it makes a lot of sense to get jj=1,
>> jj=length(26)
jj =
1
Here is the complete code
for jj = 1:length(tcal);
calpre= HADCP.pressure(hmin:hmax);
x= cast(calpre, 'double');%%%changing data type
kk =1:1:length(x);
B=repmat(reshape(x(kk),1,1,length(x)),20,40);
h2(:,:,jj)=h(:,:,jj)-B(:,:,jj).*0.001;
sig1 = repmat(sig,[1 1 26]);
sig2(:,:,jj)=sig1(:,:,jj).*(h2(:,:,jj)./h(:,:,jj));
C(:,:,jj) = max(sig2(:,:,jj),[],1);
Sca1l = permute(Sca1 ,[3 2 1]);
Sca13(:,:,jj)=griddata(sig1(:,:,jj),bet,Sca1l(:,:,jj),C(1,:,jj),bet(1,:)); Sca13=squeeze(Sca13(1,1:17,jj));
end
It doesn't run. There appears to be a fragmentary line
h3=h(end+ 2.*tan(0.06).*R
Also, it makes no sense if indeed tcal=26. As I told you length(tcal) is then equal 1 and jj will not loop.
h3=h(end+ 2.*tan(0.06).*R is commented line sorry I had to delete it. tcal has 26 data and not just 26. And there are some files which I didn't present. Yes , jj becomes 25 ,1 and 26 when I run in different modes and my question is why it changes this way and what can I do about it? thanks..

Answers (0)

This question is closed.

Asked:

on 24 Oct 2012

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!