Hello, I am having problems with some text string errors in my code. Any help would be appreciated. Here is a snippet of my code.

clear all

value = input(['Please enter a positive real numerical ' ...
    'measurement of volume:']);

initial = input(['Please select a starting measurement unit' ...
    'from the following menu of choices \n' ...
    '(liter - l, gallon - gal, cubic feet - ft3, or bushels - bu):']);

final = input (['Please select an ending measurement unit' ...
    'from the following menu of choices \n' ...
    '(liter - l, gallon - gal, cubic feet - ft3, or bushels - bu):']);

[final_conversion] = conversion (initial, final, value);

if strcmp(initial, 'l') && strcmp(final, 'gal')
    disp ([num2str(value),' liters is equal to ' ...
        ,num2str(final_conversion), ' gallons.'])

If I run the program I am getting the following errors:

??? Error using ==> input
Undefined function or variable 'l'.

Error in ==> hw2 at 11
initial = input(['Please select a starting measurement unit' ...

Any guidance would be greatly appreciated!

Disp and input should just take plain ol' strings. I'm not sure what you are trying to do with the [ ] but I don't believe it's correct. In the case on the last 2 lines you'll have to use something like sprintf to make a string out of the numerical values and the text and then display that string. I don't have a copy of Matlab to test it on but that's my recollection for the disp and input part.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.