我有一个函数,它在一个人无效的字段名称
function person = prompt_person()
name = input (' Whats your name ? ' , 's') ;
day = input (' What day of the month were you born ? ') ;
month = input (' What month were you born ? ') ;
year = input (' What year were you born? ') ;
phone = input (' Whats your telephone number ? ') ;
date_of_birth = struct ('day', day, 'month', month, 'year', year) ;
person = struct ('name' , name, 'date_of_birth' , date_of_birth , 'phone' , phone) ;
end
的personalia但我不断收到错误信息“无效的字段名‘名’”,“错误消息prompt_person(线8)我不知道什么是错,因为我试图创建一个简单的小测试功能:
function [out] = tes()
word=input('Insert word here ','s');
num=input('Insert number here ');
out= struct('Number1', word, 'Number2', num);
end
,它工作得很好,即使它似乎是完全相同的代码,让我在toruble在第一个功能。任何想法发生了什么?
尝试使用'personName'作为变量名称。 – Vuwox
无法在这里重现此...您使用什么MATLAB版本? –
我正在使用Matlab r2013a – user100620