Plotting matrix with anonymous function
1 view (last 30 days)
Show older comments
Please need help with this i stuck on this part of the problem.
- Now write a plot function that plots t versus y, using mXY.
- How do you get the first row of mXY? The second row?
- Now plot markers at every 10th sample point, on top of the function plot. Again,use mXY. How do you get every 10th sample point from mXY?
- Now create a 2x2 rotation matrix that rotates by 45 degrees.
- Multiply mXY by this matrix to create a new matrix, mXYrot.
- Plot mXYrot on top of your initial graph.
clear
clc
clf
% Create a matrix and use matric multiplication
% Write an anonymous function for the equation y(t)=t.^2*cos(6*t).
y_Func=@(t)t.^2.*cos(6.*t); % The anonymous function
% The function on the range t=[0,4pi]
t=0:4*pi;
% Generate 40 samples of the function in the range [0,4pi]
ts=linspace(0,4*pi,40);
% Generate 40 samples and create a tSample and ySample array each with 40 points
tSample=ts;
ySample=y_Func(ts);
% Combine tSample and ySample values into a 2 X 40 matrix
mXY=([tSample;ySample]);
plot(mXY,tSample,'r',mXY,ySample,'k')
0 Comments
Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!