- in the middle of an identifier (which would have to start with a letter, not a number or underscore)
- in a single-quoted character vector or double-quoted string object
- in a comment
- A number may be directly followed by i or j to indicate multiplication by sqrt(-1), such as 5i meaning 5*sqrt(-1). i and j are case-sensitive for this purpose
- A number may be directly followed by e or E or d or D provided that is followed by an optional + or - that is then followed by an integer; this indicates an exponent. For example 5.2e3
- A 0 at the beginning of a number may be immediately followed by a b that is then followed by a series of 0 and 1 to indicate binary numbers. The sequence of binary numbers may be followed by s or u and then the integer 8, 16, 32, or 64
- A 0 at the beginning of a number may be immediately followed by a x that is then followed by a series of hex digits 0 to 9, A-F or a-f, to indicate hexadecimal numbers. The sequence of hexadecimal numbers may be followed by s or u and then the integer 8, 16, 32, or 64
plot with equals in matlab
2 次查看(过去 30 天)
显示 更早的评论
hey, what is the problem with this code -
x=linespace(-10,10,2);
yy=sin(x)+0.2*sin(2x)-0.3*sin(3x);
zz=1/0.1+abs(sin(x)+0.2*sin(2x)-0.3*sin(3x));
hold on
plot(x,yy,'--g')
plot(x,zz,'-r')
hold off
axis equal
grid on
legend('y(x)','g(x)')
i get this note -
Error: File: Untitled4 Line: 3 Column: 20
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets instead of parentheses.
0 个评论
回答(1 个)
Walter Roberson
2020-10-19
yy=sin(x)+0.2*sin(2x)-0.3*sin(3x);
MATLAB has absolutely no implied multiplication anywhere. Not even in the symbolic toolbox. 2x is not a valid expression in MATLAB.
The only cases in which a number can be directly followed by a letter in MATLAB are:
In all other cases, you need an operator between the number and the letter, such as 2*x intead of 2x.
4 个评论
Walter Roberson
2020-10-19
Is there a point in calculationg 1/0.1 instead of just writing 10 instead?
Or is zz supposed to be 1 divided by a long expression? Remember to use () as needed.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!