error: Too many output arguments
Show older comments
my goal is to obtain a matrix A (2x2) using a function called somma:
function [] =somma (x,y)
z=x+y
my script code is :
clear all
clc
x=1:2;
y=3:4;
A=zeros(length(x),length(y));
[x1,x2]=meshgrid(x,y);
for i=1:length(x);
for j=1:length(y);
A(i,j)=somma(x1(i,j),x2(i,j));
end
end
A
the error reported is:
Error using somma
Too many output arguments.
Error in untitled5 (line 9)
A(i,j)=somma(x1,x2);
Accepted Answer
More Answers (2)
ahmed nebli
on 2 Sep 2018
0 votes
when writing the for loop it dosen't end with a ; and next the second for loop need to be under the first for loop and decaled by one tab, see syntax in this example https://www.mathworks.com/help/matlab/ref/for.html
1 Comment
Marco Barbarossa
on 2 Sep 2018
Marco Barbarossa
on 3 Sep 2018
0 votes
1 Comment
Image Analyst
on 3 Sep 2018
Or, better if you can, upgrade your release to the latest version.
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!