早教吧 育儿知识 作业答案 考试题库 百科 知识分享

Matlab报错为Attemptedtoaccessf(64.4);indexmustbeapositiveintegerorlogical.编码如下:forx=11,11;190;64.4;37.25;110;11;8.3;9.1;41.5;y=f(x);ifx<50f(x)=1;elseifx<110&x>50;f(x)=(x-50)/60;elseifx>=110f(x)=0;

题目详情
Matlab 报错为Attempted to access f(64.4); index must be a positive integer or logical.编码如下: for x=11,11;190;64.4;37.25;110;11;8.3;9.1;41.5; y=f(x); if x<50 f(x)=1; elseif x<110&x>50; f(x)=(x-50)/60; elseif x>=110 f(x)=0; end end disp(y)
▼优质解答
答案和解析
你的脚本里f是一个数组,把f定义成一个带参数的函数就行了。
看了Matlab报错为Attemp...的网友还看了以下: