I got an online question which I couldn’t understand.
The question is:
Create a script to ask the user to create a random number using the following equation :
- Plot
x(t)
with customize the figure yellow and red color and dash line.- Solve the equation with symbolic and differentiate it.
I tried to solve it as following:
clc; clear all;
syms x;
Xt = int(100*rand*sin(x),-100,100);
plot(Xt); % The first question
Y = solve(100*rand*sin(x));
Y2 = diff(Xt,x);
The problem I face is that Xt
, Y
and Y2
are all zeros. Did I understand the question right? How to solve it?
Possibly, could plot the functions with respect to
x
. Kinda concerned since the function is calledX(t)
though. Seems like it should be changing with respect tot
or some kind of time variable. The colour and line properties can be configured by adding the short-hand for the colour followed by the line type in this case I used a dashed red line denoted asr--
in thefplot()
line. In this example, I also usedhold on
to add a yellow underline. If you need the figure background colour to be yellow addset(gcf,'color','y');
to configure the current figure,gcf
. Not quite sure which portions or plots need the yellow colour. To plot symbolic functions using thefplot()
function can be a useful method. This function can optionally take a second argument that is an array describing the horizontal/x-axis bounds/range to plot the function for. Also note thatrand
will only evaluate to doubles in the range from 0 to 1.Ran using MATLAB R2019b