필터 지우기
필터 지우기

how can i write a function with a range of values for example speed between 100 and 150.

조회 수: 1 (최근 30일)
I am trying to design a compressor with a range of values. The rotation speed and blades are not fixed and have ranges. How will I input this so that i can be able to calculate the values at each of the ranges.
  댓글 수: 1
John Chilleri
John Chilleri 2017년 1월 30일
Would you mind attaching your current code? It shouldn't be too difficult to convert your function to something that can accept vectors, and redefine your variables with either:
Var = 100:Desired_Increment:150;
or
Var = linspace(100,150,n);
where n is the number of desired, equally spaced points in the range.

댓글을 달려면 로그인하십시오.

답변 (1개)

Iddo Weiner
Iddo Weiner 2017년 1월 31일
I agree with Jhon, more specific details could help understanding the problem..
But 1 possibility would be throwing an error if the input value is out of range, e.g. add to the beginning of the function:
Range = [100 150];
if input_val < min(Range) || input_val > max(Range)
error('input value out of range')
end
This will not allow the function to run with values you do not want to treat

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by