Effacer les filtres
Effacer les filtres

Input of array into equation won't return array?

2 vues (au cours des 30 derniers jours)
Ian Gargan
Ian Gargan le 12 Avr 2017
Commenté : Ian Gargan le 18 Avr 2017
If I input x=1:1:10, then I input y=(3*x)/(3+x). Why do I get y=2.0497 returned instead of an array?
  1 commentaire
Stephen23
Stephen23 le 17 Avr 2017
@Ian Gargan: you are using the wrong operator mrdivide /, when you should be using rdivide ./. Read about the differences here:

Connectez-vous pour commenter.

Réponse acceptée

Ankitha Kollegal Arjun
Ankitha Kollegal Arjun le 17 Avr 2017
Since 'x' is a vector, the '.' operator should be applied for performing division. The '.' operator will perform the operation on each element of the vector. The code will look like:
x = 1:1:10;
y = (3*x)./(3+x);

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by