I don't know why you're saying it's an invalid expression. Help me
1 回表示 (過去 30 日間)
clear all; close all;
title('HW#1 test -2_pi and 2_pi')
xlabel('-2pi < x < 2pi')
ylabel('sin(x^2) and cos(x)^2')
legend('y = sin(x)','y = cos(x)')
その他の回答 (1 件)
John D'Errico 2023 年 9 月 12 日
編集済み: John D'Errico 2023 年 9 月 12 日
You NEED to learn about the dotted operators, thus .*, ./, and .^ operators.
When x is a vector, for example, this:
x = 1:5
So we see it is a row vector. MATLAB has special uses for ^, * and / that apply to linear algebra, vectors and matrices. So if you want only to square the elements of x,
The dotted operator tells MATLAB to square EACH element of the result. Similarly, we could do this
Again, multiply each pair of elements in turn.
But when you did this:
It generates an error.
I would strongly suggest the MATLAB Onramp tutorials.