I have no matlab experience and i need this done

EDIT: think i got it nevermind

4 件のコメント

Guillaume
Guillaume 2015 年 2 月 26 日
You are basically asking us to help you cheat on your assignment?
Stephen23
Stephen23 2015 年 2 月 26 日
Do we get the course credits too?
John Smith
John Smith 2015 年 2 月 26 日
sorry guys I should have been more clear with my question. i don't want you to write it for me. i want help/suggestions etc.
Titus Edelhofer
Titus Edelhofer 2015 年 2 月 26 日

サインインしてコメントする。

回答 (2 件)

Konstantinos Sofos
Konstantinos Sofos 2015 年 2 月 26 日

0 投票

Hi John,
As Guillaume told you, you are basically asking for someone to do your assignment. I wont do this but i can give you some guidelines that i am sure that will help you to understand better your staff and MATLAB functionality.
1. Have a look in linspace (type in your command window doc linspace)
2. see in matlab documentation the sin function (doc sin). Also Frequency = 1/Cycle time so -> T = 1/5=0.2. You have to plot the sine of your time x with step t=0.2 .
3. see matlab documentation for plot (doc plot). e.g. plot(x,y,'*')
4. see matlab documentation for normal distributed random numbers (doc randn)
5. x*y -> vector multiplication and x.*y -> point-wise multiplication
6. http://de.mathworks.com/help/matlab/matlab_prog/create-functions-in-files.html
7. If you did the above you know for sure this step.
MATLAB and in general programming is something that you learn only and only if you play with it.
Regards

5 件のコメント

Michael Haderlein
Michael Haderlein 2015 年 2 月 26 日
...just a comment to point 1: If you have a fixed number of elements, linspace is the easiest way to create the array. But here, you have the increment. Therefore, the colon operator : is better to use.
John Smith
John Smith 2015 年 2 月 26 日
thank you for your answer. i'm sorry about the confusion; i was not asking you to do my assignment for me and i appreciate your help. i have updated the question with code i have thus far based on your help and research of done on my own. i am currently stuck on "part" 4
Joep
Joep 2015 年 2 月 26 日
Try for function
for i=1:size(x)
y(i)=randn
end
Stephen23
Stephen23 2015 年 2 月 26 日
編集済み: Stephen23 2015 年 3 月 9 日
Actually don't use that code, as it is very poor MATLAB code. Lets have a look at why:
for i=1:size(x)
y(i)=randn
end
  • it will be slow (no array preallocation)
  • it calls one function multiple times unnecessarily
  • it obfuscates what 1:size(x) will return, as size(x) will return an vector with atleast two elements, so what is 1:size(x)? Perhaps the author meant to use numel ?
  • it wastes space.
  • it uses i as the variable name, which is the name of the inbuilt imaginary unit .
Instead one should learn to use MATLAB's functions properly. Reading randn 's documentation will explain that one can do this instead:
y = randn(1,numel(x))
Or perhaps
y = randn(size(x))
Is faster, neater, uses no loops, and much easier to read.
Joep
Joep 2015 年 3 月 6 日
Oh yeah forgot about that randn can also work like that. I don't use that function a lot.

サインインしてコメントする。

Joep
Joep 2015 年 2 月 26 日
編集済み: Joep 2015 年 2 月 26 日

0 投票

create a sequence
sequence = start:step:end;
create a sine function
Amplitude*sin(frequenty*2pi*variable+phase)
plot t vs s
Try F1 plot and you see!!
I'm not to do here for your home work but I hope make something clear which you can work on.
Update: Try for function
for i=1:size(x)
y(i)=randn
end
Last one is for you that one is to easy.

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2015 年 2 月 26 日

編集済み:

2015 年 3 月 9 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by