简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM