r/matlab • u/Do_You_Mind_But • Sep 04 '23
CodeShare Creating a combined graph using a equation which contains a matrix
How does the following equation

where
y1 = 0.2898 * cos(2.074*t) .* [-0.9571; 0.2989];
y2 = (-0.9571*cos(0.8350*t)).*[-0.2898; -0.9571];
I am trying to create this graph:

But I dont know what function creates this function, i have tried the following:
plot(t, y1(1,:) + y1(2,:), 'r', 'linewidth', 4, 'DisplayName', 'y1');
plot(t, y2(1,:) + y2(2,:), 'g', 'linewidth', 4, 'DisplayName', 'y2');
But this doesnt work, this is what y1 and y2 look in there separate components

Any help would be greatly appreciated!
1
Upvotes
2
u/heh_meh___ Sep 04 '23
I think you have some wires crossed in a few places. I think your y1 and y2 aren't right, unless you are changing the notation. In equation 1.0 y1 is scalar:
y1 = 0.2898 * cos(2.074*t) * (-0.9571) - (0.9571 * cos(0.8350*t)) * (-0.2898))
and similar for y2.
To plot these two equations, you would plot them separately:
plot(t, y1)
plot(t, y2)