for 루프를 사용하여 셀 배열에서 일부 계산을 시도하지만 마지막 루프의 결과 만 표시됩니다. Matlab에서 모든 루프에 대한 결과를 표시하고 싶습니다.출력 반복은 Matlab의 루프에서 발생합니다.
기울기 =
4.4089
시간 =
0.5794
위치 =
을 : 내가 무엇을 얻을입니다slope=[];
time=[];
position= [];
for p=1:max(L) % max L gives the number of result{n}. so if max(L)=6 we have from result{1} to result{6} and therefore 6 final values that i want to get%
a=result{n}(:,1);
b=result{n}(:,2);
end
B = [ones(length(a),1) a] \ b % this is to obtain the slope and intercept of a lin. regresion
slope = B(2)
time = result{n}(end,1)-result{n}(1:1)
position = (slope.*result{n}(end,1)+intercept)-(slope.*result{n}(1:1)+intercept)
출력에 순간 : 여기에 코드가있다
2.5546
이 결과는 정확합니다. 그러나이 값은 결과 {6}로 얻은 값이므로 이전 값이 필요합니다.
도움을 주시면 감사하겠습니다.
미리 감사드립니다.