Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Please help me with matlab!

Status
Not open for further replies.
K

kplonsky

Guest
I am having a really hard time trying to answer this question.
"Create a normal distribution of temperatures (Gaussian distribution) with a
mean of 70F, and a standard deviation of 2 degrees, corresponding to 2
hours duration. You’ll need a temperature for each time value from 0 to
120 minutes."
I believe I have to use something like this "temp=randn(1,120)*2+70" but I think I am very far off. My matlab book doesn't show how to do Gaussian distribution.

Please help!!
 

I believe I have to use something like this "temp=randn(1,120)*2+70" but I think I am very far off.
Why do you think you are very far off? It's OK.
The only point is that if you need a sample for each time from 0 to 120 including start and stop, you would need 121 samples.
The question doesn't say nothing about it, but the samples generated in that way are idependent.
Regards

Z
 
  • Like
Reactions: kplonsky

    K

    Points: 2
    Helpful Answer Positive Rating
Thank you for your help, the numbers looked weird in matlab.
temp=randn(1,121)*2+70
That should give me what I am looking for then right?
 

Yes, that should give you what you are looking for.
Why the numbers look weird?
Regards

Z
 
  • Like
Reactions: kplonsky

    K

    Points: 2
    Helpful Answer Positive Rating
Thank you for your assistance on that problem. I ran into another now...

The distance a projectile travels when fired at an angle θ is a function of time and can be divided into horizontal and vertical distances :
Ht= t *Vo*cos(θ)
Vt=t*Vo*sin(θ) – ½gt
2
where:
Ht is the distance traveled in the x direction
Vt is the distance traveled in the y direction
Vo is the initial velocity
g is the acceleration due to gravity, 9.8m/s
t is the time

a. For the projectile just described and fired at an initial velocity of 100 m/s and a launch angle of pi/4, find the distance traveled both horizontally and vertically ( in the x and y directions ) for times from 0 to 20 seconds. Graph horizontal distance versus time on one plot, and in a new figure window plot vertical distance versus time (time on x – axis). Don’t forget the title and the axis labels.

Vo=100; %m/s
time=(0:20); %Seconds
g=9.8; %Gravity m/s^2
Ht=time.*Vo*cos(45);
Vt=time.*Vo*sin(45)-(1/2)*g.*t^2;

I was having a hard time using radians in Matlab so I switched it to degrees instead. Sorry for this huge mess on the forum, I am struggling with this program. I don't think I put the equation into Matlab correctly because the plots all come out to be the same.
 

Hi,

1) radians or degrees:

sin(), cos(), etc. use arguments in radians.
sind(), cosd(), etc. use arguments in degrees.
So you have to correct your code.


2) For converting angles from degrees in radians and vece versa:

angle_in_radians = angle_in_degrees * pi/180;

angle_in_degrees = angle_in_radians * 180/pi;


3) I recommend to put this line at the beginning:

thetaD = 45;

ant then use thetaD instead of a particular value.


4) In the line

Vt=time.*Vo*sin(45)-(1/2)*g.*t^2;

what is t? It should be like this:

Vt=time.*Vo*sind(thetaD)-(1/2)*g*time.^2;


Regards

Z
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top