Guest User

Untitled

a guest
Dec 12th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. syms q a x
  2. f=a(q+1)*x(2)^q
  3. y(2) = symsum(f, q, 0, m)
  4.  
  5. % Inputs , for example x=[1,2,3,..,10] and a=[5,6,7,8]
  6.  
  7. x=1:10
  8. a=[5,6,7,8]
  9.  
  10. % m <= length(a)
  11.  
  12. m=3
  13.  
  14. % temporary matrices
  15.  
  16. [tx,ta] = meshgrid(x,a)
  17. [~,tm]=meshgrid(x,0:m)
  18. t=ta(1:m+1,:).*tx(1:m+1,:).^tm(1:m+1,:)
  19.  
  20. % y is your result and has equal elemnts to x matrix
  21.  
  22. y=sum(t,1)
  23.  
  24. % some outputs
  25.  
  26. y(2)
  27. y(3)
Add Comment
Please, Sign In to add comment