输入字符在MATLAB语句或表达式中无效

问题描述 投票:0回答:1

我有此代码:

[x,y]=meshgrid([-2:0.01:2],[-2:0.01:2]); 
z1 = sin(x+1) - y – 1,2;
subplot(121);
contour(x,y,z1);
grid on;
xlabel(‘name’)
ylabel('group')
title('surname');
hold on;
z2 = 2.*x + cos(y) - 2;
subplot(122);
contour(x,y,z2);
hold on;
xlabel('name')
ylabel('group')
title('surname');

运行时出现错误:

Error: The input character is not valid in MATLAB statements or expressions.

在此行上引用:z1 = sin(x + 1)-y – 1,2;

matlab
1个回答
0
投票

第二行上的第二个“减号”是一个破折号,而不是减号。用普通的减号代替它,您的代码应该可以使用。

© www.soinside.com 2019 - 2024. All rights reserved.