Two basic MATLAB problems help

1 次查看(过去 30 天)
Paul
Paul 2013-9-26
回答: Jan 2013-9-27
Hi, I'm a student studying engineering and I have my first exam tomorrow on MatLab. I'm going through some practice problems and ran into two that I don't understand, I posted them below and was wondering if anyone could help me out! Thanks
6) Assume that the function *diff* does not exist. Write your own expression(s) to accomplish the same thing for a vector.
7) Find expressions that will evaluate the function f of two variables x and y:
f(x,y) = 3*x - y
where x ranges from 1 to 2 and y ranges from 1 to 5.
  3 个评论
Walter Roberson
Walter Roberson 2013-9-27
编辑:Walter Roberson 2013-9-27
#6, diff() can be done without any loop.
#7 can be done without any loop and without any meshgrid (or ndgrid. or repmat)
Jan
Jan 2013-9-27
编辑:Jan 2013-9-27
These problems are not complicated. So I wish you good luck for your first exam tomorrow.

请先登录,再进行评论。

回答(2 个)

Image Analyst
Image Analyst 2013-9-27
Hint: type out vec(1:end-1) and vec(2:end) and see what that shows.

Jan
Jan 2013-9-27
#7: When x ranges from 1 to 2 only, you can write down the equation for x=1 and x=2 manually. If you define y=1:5, the work is done already.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by