Sizes of the internal matrix should match?

this is my first matlab script, so this question may seem basic and dazzlingly obvious, but I'm a little stuck right now.

I have a matlab script of two lines:

x = linspace(0,4*pi,100);
y = exp(-x) * sin(x);

I'm leaving the tutorial on creating a two-dimensional chart on Mathworks. I want to build f (x) = e ^ (- x) sin (x) in the range from 0 to 4pi, but I get that the dimensions of the inner matrix should coincide with the error in the second row. I’m not sure what’s going on, because I don’t think that I’m creating any matrices right now. Any help would be appreciated! Is there something simple with the syntax that I am missing? Thank you

+4
source share
2 answers

, , , MATLAB, MATLAB . , :

y = exp(-x) * sin(x);

, . , , - . , exp(-x) sin(x). @ellieadam , , , , dot (.) . , :

y = exp(-x) .* sin(x); %// Note the dot!

.


, . , :

A = [1 2;
     3 4];

B = [4 3;
     2 1];

A * B MATLAB, :

>> A * B

ans =

     8     5
    20    13

, . A .* B, , :

>> A .* B

ans =

     4     6
     6     4

, A B. A , B, , . , . , . , .

@ellieadam, MathWorks, , :

http://www.mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html

+13

x . , exp(-x) sin(x), . .

( , ), :

x = linspace(0,4*pi,100);
y = exp(-x) .* sin(x);

.* ./ .

, .

+4

All Articles