function [b,c]=a(str)
line='xxyy';
if (strcmp(str,line(1:2)))
b=10;
c=20;
else
b=30;
c=40;
end
运行情况:输入d=a('xx')
输出d=10
为什么不是返回d=[10 20]?求解答~~
请教一个matlab问题,字符串判断小程序,返回值为什么只返回一个?
答案:2 悬赏:30
解决时间 2021-11-29 13:12
- 提问者网友:喵星人荷西
- 2021-11-28 19:31
最佳答案
- 二级知识专家网友:嗷呜我不好爱
- 2021-11-28 20:10
因为你自己引用了两个输出啊。。。
function [b]=a(str)
line='xxyy';
if (strcmp(str,line(1:2)))
b(1)=10;
c(2)=20;
else
b(1)=30;
c(2)=40;
end
这样才能达到你的效果
function [b]=a(str)
line='xxyy';
if (strcmp(str,line(1:2)))
b(1)=10;
c(2)=20;
else
b(1)=30;
c(2)=40;
end
这样才能达到你的效果
全部回答
- 1楼网友:许你一世温柔
- 2021-11-28 21:27
eval(s), where s is a string, causes matlab to execute
the string as an expression or statement.
[x,y,z,...] = eval(s) returns output arguments from the
expression in string s.
eval(s)是让matlab执行字符串s,返回值是执行字符串s的输出参数,例如
>> eval('a=3') %返回的结果是:
a =
3
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯