Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to calculate it in Matlab?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have vectors . How to calculate or in Matlab?
댓글 수: 0
답변 (2개)
Mohammad Sami
2020년 5월 27일
You have two options.
First option is to use symbolic sum "symsum" if you have symbolic math toolbox.
syms y;
N = 10;
F1 = symsum(y^2,k,1,N);
The second option is to evaluate the expression then sum it.
f = @(y) y.^2;
N = 10;
y = 1:N;
F1 = sum(f(y));
댓글 수: 0
Image Analyst
2020년 5월 27일
Try this with your two vectors that you say you already have:
% Define some x and y (you apparently already have these but I need to make them).
x = 2 : 3 : 50; % Whatever....
y = 1 : 40
% Define N and do the two sums:
N = 3;
sum1 = sum(y(1:N).^2)
sum2 = sum(x(1:N).* y(1:N))
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!