how do make the integral a vector

integral = 0
for i = 1:n
r_left = (a+(i-1)*h);
r_right = (a+i*h);
% Functions
f_left = f(r_left);
f_right = f(r_right);
% Integral
integral = integral+(h/2)*(f_left+f_right)
end

답변 (1개)

madhan ravi
madhan ravi 2018년 11월 14일
편집: madhan ravi 2018년 11월 14일

0 개 추천

integral=cell(1,n);
integral{1}=0;
for i = 2:n
r_left = (a+(i-1)*h);
r_right = (a+i*h);
% Functions
f_left = f(r_left);
f_right = f(r_right);
% Integral
integral{i} = integral{i-1}+(h/2)*(f_left+f_right) %put {i} next to integral to avoid overwriting
end
celldisp(integral) %to view values
integral = cell2mat(integral) %to convert to double array

카테고리

도움말 센터File Exchange에서 Modify Image Colors에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2018년 11월 14일

편집:

2018년 11월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by