problem is related to sum of array elements ;my code pass the test individually but combinedly it is showing error

This topic has been permanently closed and transferred to MATLAB Answers.


%%https://in.mathworks.com/matlabcentral/cody/problems/3-find-the-sum-of-all-the-numbers-of-the-input-vector/solutions/new#
%Above is the complete link of question that is ask and below i am providing my code for %this problem, please guide how do i rearrange this so that i can pass all the test at a time.
function y = vecsum(x)
x= 1:100;
y1= sum(x(1,[1]));
y2= sum(x(1,[1 2 3 5]));
y3= sum(x);
y=[y1 y2 y3];
end
Josh
Josh on 16 May 2024 (Edited on 16 May 2024)
the MATLAB Answers community is better for posting questions like this:
if you're strugglng with this question, it would probably serve you better to spend some time in the self-paced courses: MATLAB Onramp and MATLAB Fundamentals:
https://matlabacademy.mathworks.com/

Tags