facing error to execute

5 Ansichten (letzte 30 Tage)
Urvashi
Urvashi am 11 Nov. 2022
Kommentiert: Image Analyst am 11 Nov. 2022
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);

Antworten (1)

Image Analyst
Image Analyst am 11 Nov. 2022
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 Kommentare
Urvashi
Urvashi am 11 Nov. 2022
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.
Image Analyst
Image Analyst am 11 Nov. 2022
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(:));

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu AI for Wireless finden Sie in Help Center und File Exchange

Produkte


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by