Well see the reason why I asked this question was because I was trying to solve a problem for this course that I'm taking in which I'm trying to learn how to use MATLAB. This question came up because I was confused by the math that was required to solve the question. Basically I'm trying to create a conversion table from degrees Celsius to degrees Rankine were the user inputs the starting temperature in degrees Celsius and the increments at which degrees Celsius is increased by from row to row.
"Generate a table of conversions from Celsius to Rankine. Allow the user to enter the stating temperature and the increment between lines. Print 25 lines in the table. Use disp and fprintf to create a table with a title, column headings, and appropriate spacing."
disp('The table about to be generated is a degrees Celsius to degrees Rankine conversion table, and will contain 25 lines.')
A=input('At which starting temperature, in degrees Celsius, would you like the table to start at?');
B=input('At what increment would you like the degrees Celsius to be displayed?');
table=[A:B:?;C_to_R(A:B:?)];
disp('degrees C to degrees R')
disp('degrees C degrees R')
fprintf('%4.2f %12.2f\n',table)
and I was having trouble coming up with what to place in the question marks. Note that C_to_R is a function I created in a earlier problem were the user inputs value(s) in degrees Celsius to convert them to degrees Rankine. Note that the notation "A:B:?" is nothing more than a series of values were A is the starting point, B is the increments at which to increase between each value after A, and ? is the ending point at which MATLAB doesn't list values past.
Hence 0:2:10 yields
0 2 4 6 8 10
and the equation I came up with if we let the three values be A:B:C and L the number of lines desired, was
C/B + 1 = L
hence
0:2:10 would yield 6 values because
C=10
B=2
10/2 + 1 = 5 + 1 = 6
I however realized that
C/B + 1 = L
didn't work on all occasions when C/B didn't produce a whole number and that the proper equation was actually
floor(C/B) + 1 = L
which works every single time
I'm just lost as how to solve for C and sense it's a value that I have to enter and not the user of the program I'm making I have to some how come up with the value myself given the number of lines, this case L=25, the starting value A, and the increments at which to increase B... but A really is irrelevant
hence I'm stuck because a range of values is the yielded answer when solving
floor(C/B)+1=25
sense were given L=25