Function only computing first element of array used as input

Technical Source
2 min readApr 3, 2023

--

I am trying to use a MATLAB function to generate a plot for the function :

As such I am using the linspace function to generate an input array that I then aim to give to the function i wrote to get data to be plotted. But the function only processes the first element of the Array generated by linspace. The function appears to work correctly for singular values but not for arrays.

function S = FXSUM(x) 
Tot = 0; % reset Total
for n = 2:x % for loop for Function Summs at a iterations
it = (1/(n*((log(n))^2))); % provided function
Tot = Tot + it % sum of function iterations
end
S = Tot; % Out value equal to function iterrations total
end

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

Your function is not written to accept a vector as input. You likely need to add a second loop to run for each element of your input vector.

Right now, it creates your loop counter using 2 and the first element of

x = 5:8
x = 1×4
5 6 7 8

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.