MATLAB Answers

How to calculate it in Matlab?

2 views (last 30 days)
ihs ihs
ihs ihs on 27 May 2020
Answered: Image Analyst on 27 May 2020
I have vectors . How to calculate or in Matlab?

  0 Comments

Sign in to comment.

Answers (2)

Mohammad Sami
Mohammad Sami on 27 May 2020
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 Comments

Sign in to comment.


Image Analyst
Image Analyst on 27 May 2020
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 Comments

Sign in to comment.