While loop to detect 0 slope
이전 댓글 표시
Hello everyone,
so I'm currently trying to make a code that will separate some data. To do so, I came up with a code that I thought would work, and I've tried looking at the what the error message mean, but I cant understand. My code is the follwoing
*g=0; j=0; A=[5 5]; h=0; slope=5; while (g<1785) & (A(1,1)>0) & (h<0.15) h = AverageStrain(1+g:20+g,:); i = AverageStress(1+g:20+g,:); A = polyfit(h,i,1); j = g+10; g = g+20; end
Cycle1UpStrain=AverageStrain(0:j,1);*
The error message i receive is ;
*Subscript indices must either be real positive integers or logicals.
Error in MTSAnalyser (line 43) Cycle1UpStrain=AverageStrain(0:j,1);*
here, the files AverageStress and AverageStraain are 1785x1 variables. I tried doing a linear fit of 20 data points at the time so that when the linear slope calculated is 0 are negative, it stops and extracts the number j.
j would be used to create a variable made of a fraction of AverageStress and AverageStrain, data points 1 to j. (afterwards I would make it something like j to a new variable limit)
Also, my value of A always ends in something like [574, -64], which is weird since I wanted it to stop at a slope equal 0 or smaller, which is the first row, first column of A.
I'm quite new to Matlab, so try not to assume I know a whole bunch.
Thank you for your help! N
댓글 수: 1
Star Strider
2014년 6월 4일
Formatted code:
g=0;
j=0;
A=[5 5];
h=0;
slope=5;
while (g<1785) & (A(1,1)>0) & (h<0.15)
h = AverageStrain(1+g:20+g,:);
i = AverageStress(1+g:20+g,:);
A = polyfit(h,i,1);
j = g+10;
g = g+20;
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!