My program is supposed to take input and use this to calculate the corresponding hydrogen. My code is this:
function Q = hydrogenusage(P)
P = 0:1:4000;
Q = 79.987*P+42.942;
plot(P,Q)
xlabel('Power (W)')
ylabel('Usage (l/minute)')
title('Hydrogen usage (no leak)')
axis([0 60 0 4000])
grid on
if nargin == 0
Q = input('Enter the power to get the hydrogen usage: ');
end
Entering 'hydrogenusage' gives me:
Enter the power to get the hydrogen usage
I enter for an example 40
If I fill that in my formula it gives me Q = 3242.422.
But when I enter 40 it gives me this:
It looks wonderful and it very accurately repeats what I just entered but I'd like it to give me the answer of the function.
How can I make this happen?