Checking multiple values in an equation in MATLAB

For a given value of x, how could you use MATLAB to find what the smallest z value greater than 5 if z=x/y, and y values are considered in increments of 6 (6, 12, 18,...)?

답변 (2개)

Torsten
Torsten 2022년 9월 10일
편집: Torsten 2022년 9월 10일
format long
x = 1271;
[y,z] = result(x)
y =
252
z =
5.045365079365079
function [y,z] = result(x)
if x <= 30
disp('Problem not solvable')
y = [];
z = [];
return
end
if mod(x,30)==0
y = x/5 - 6;
else
y = 6*floor(x/30);
end
z = x/y;
end

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2022년 9월 10일

편집:

2022년 9월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by