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

6 views (last 30 days)
Fiona Ngethe
Fiona Ngethe on 30 Jan 2017
Answered: Iddo Weiner on 31 Jan 2017
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 Comment
John Chilleri
John Chilleri on 30 Jan 2017
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;
Var = linspace(100,150,n);
where n is the number of desired, equally spaced points in the range.

Sign in to comment.

Answers (1)

Iddo Weiner
Iddo Weiner on 31 Jan 2017
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')
This will not allow the function to run with values you do not want to treat

Community Treasure Hunt

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

Start Hunting!