i want to write a code where equation is y=x*x. if y=100 what is the value of x?

1 次查看(过去 30 天)
i have written
z=100;
for x=1:1:20
y=x*x
if y==z
fprintf(x)
end
end

采纳的回答

Stephen23
Stephen23 2020-9-18
编辑:Stephen23 2020-9-18
>> f = @(x) x.^2 - 100;
>> x = fzero(f,pi)
x = 10
  3 个评论
Stephen23
Stephen23 2020-9-18
编辑:Stephen23 2020-9-18
This
@(x) x.^2 - 100
defines an anonymous function:
fzero uses that function to find the zero crossing (i.e. the input value for which the function output is zero).

请先登录,再进行评论。

更多回答(1 个)

KSSV
KSSV 2020-9-18
z = 100 ;
x = 1:20 ;
y = x.^2 ;
y(x==z)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by