필터 지우기
필터 지우기

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

조회 수: 3 (최근 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에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by