Vectorized Coding to Code a Function

How do I create a function fseries1, which recieves the value of k and x, and calculates and returns the sum of the series.
S=1+3*x + 5*x^3 + 7*x^5+ 9*x^7 + ... + (2k+1)*x^(2k-1)
Write this function using vectorized coding, i.e. by using the array of coefficients [3 5 6 ...] and the array [ 1 3 5 ...] of powers of x/ Display the value of sum in the main script with 4 decimal places.

댓글 수: 3

Joseph DeMaria
Joseph DeMaria 2020년 11월 14일
this is my code so far, for the values k and x
Are Mjaavatten
Are Mjaavatten 2020년 11월 15일
This looks like a homework question. Take a look at these answers about homework help.
Here are some hints, though:
Please read the documentation about elementwise multiplication and power.
For the four signinficant figures, try fprintf with g format.
You may also need to read about Matlab functions.
Good luck!
Joseph DeMaria
Joseph DeMaria 2020년 11월 15일
thank you!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

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

질문:

2020년 11월 14일

댓글:

2020년 11월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by