a=[1 2 3 4];
b = vsum(a);
disp(b);
function y = vsum(x)
y = sum(x,'all');
end
I am facing below error
Error using sum
Invalid option. Option must be 'double', 'native', 'default', 'omitnan' or 'includenan'.
Error in vecadd>vsum (line 5)
y = sum(x,'all');
Error in vecadd (line 2)
b = vsum(a);

답변 (1개)

Image Analyst
Image Analyst 2022년 11월 11일

0 개 추천

I don't believe the 'all' option had been introduced in your r2016b version. Can you upgrade to the latest version. Or else do
y = sum(x(:));

댓글 수: 4

Urvashi
Urvashi 2022년 11월 11일
it's still not working
It does for me:
a=[1 2 3 4];
b = vsum(a);
disp(b);
10
function y = vsum(x)
y = sum(x(:));
end
So you didn't do what I said. Attach what you actually did so we can correct it.
Urvashi
Urvashi 2022년 11월 11일
a=[1 2 3 4];
b = vsum(a);
disp(b);
function y = vsum(x)
y = sum(x,(:));
end
error
Error: File: vecadd.m Line: 5 Column: 15
Unexpected MATLAB operator.
Why did you put a comma after the x? I did not say to do that.
You did
y = sum(x,(:));
while I said to do
y = sum(x(:));

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

카테고리

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

제품

릴리스

R2016b

질문:

2022년 11월 11일

댓글:

2022년 11월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by