Azzera filtri
Azzera filtri

help to input sqrt function

2 visualizzazioni (ultimi 30 giorni)
marwan alamah
marwan alamah il 10 Giu 2020
Commentato: Walter Roberson il 12 Giu 2020
z=sqrt(sin(x.^2+y.^2))\sqrt(x.^2+y.^2)
is this code input correct for this function
z=(sin√(x^2+y^2 ))/√(x^2+y^2 )

Risposte (2)

Walter Roberson
Walter Roberson il 10 Giu 2020
Modificato: Walter Roberson il 12 Giu 2020
z = sqrt(sin(x.^2+y.^2)) ./ sqrt(x.^2+y.^2);
  3 Commenti
marwan alamah
marwan alamah il 10 Giu 2020
it did not work
tell me it is undefined function or variable x
what should i do
Walter Roberson
Walter Roberson il 12 Giu 2020
It is not clear why you would want to compute z=sqrt(sin(x.^2+y.^2))\sqrt(x.^2+y.^2) if x and y are not defined?
Perhaps you are wanting to create a function. If so then Rohith Nomula's "myfun" would work.

Accedi per commentare.


Rohith Nomula
Rohith Nomula il 10 Giu 2020
For this
z=(sin√(x^2+y^2 ))/√(x^2+y^2 )
For x and y as single elements
z=sin(sqrt(1^2+2^2))
z=z/(sqrt(1^2+2^2))
For a function
function z = myfuc(x,y)
z= sin(sqrt(x^2+y^2))/sqrt(x^2+y^2);
end
Try declaring it this way
  1 Commento
Walter Roberson
Walter Roberson il 12 Giu 2020
The code to be implemented involves the dot versions of the operators, so the function should as well:
function z = myfuc(x,y)
z= sin(sqrt(x.^2+y.^2)) ./ sqrt(x.^2+y.^2);
end

Accedi per commentare.

Categorie

Scopri di più su Introduction to Installation and Licensing 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