# Not enough input arguments from a row vector

2 visualizzazioni (ultimi 30 giorni)
Eric Brown il 4 Apr 2022
Modificato: Torsten il 4 Apr 2022
My code is to find the roots of a quadratic using a row vector as the input. The function is called using myquad([3 4 5]) and I keep getting the error that i dont have enough input arguments. I am VERY new to matlab so please explain your answer like you're talking to a bump on a log.
if b^2 - 4*a*c > 0
x = 2;
else if b^2 - 4*a*c == 0
x = 1;
else
x = 0;
end
end
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Torsten il 4 Apr 2022
Modificato: Torsten il 4 Apr 2022
a = vec(1);
b = vec(2);
c = vec(3);
if b^2 - 4*a*c > 0
x = 2;
else if b^2 - 4*a*c == 0
x = 1;
else
x = 0;
end
end
Since you pass a vector and not three scalars, you must take it as a vector in myquad and split it in its components.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Più risposte (1)

Fangjun Jiang il 4 Apr 2022
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by