Search code examples
matlabtypeconverter

How to force my output data in a inputdlg on Matlab be a double?


I'm currently using a MATLAB to work and I need some help:

I need to convert my output data (variable: units) be a double instead of a cell because I must perform a sum:

units = inputdlg(question,title);
sum = units + i;

I've tried this code also but didn't solve my problem:

units = double(inputdlg(question,title));
sum = units + i;

Someone could help me?


Solution

  • inputdlg returns a cell array of strings. You can convert to double with str2double:

    units = str2double(inputdlg(question, title));