Clear Filters
Clear Filters

symsum with if statement or condition

2 views (last 30 days)
Masood Abbasi
Masood Abbasi on 24 Apr 2018
Commented: Masood Abbasi on 24 Apr 2018
Hi S1 = symsum(k^2 + m, k, [1 10]) I want m to be 1 when k=3 and else 0. How can i put if statement inside symsum() function
  2 Comments
Juri Maibaum
Juri Maibaum on 24 Apr 2018
Edited: Juri Maibaum on 24 Apr 2018

As it is a sum and as k=3 is occurring exactly once, you can use

S1 = symsum(k^2,k,[1,10])+m;

Or do you actually look for a more general solution?

Masood Abbasi
Masood Abbasi on 24 Apr 2018

Thanks but this is simple equation how can i add to complex equations like

here i need to replace 'p' with 1 0r 0.7 based on some value of 'i' and 'd'. How can i add conditional statement here.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!