reading strings and apying functions

1 次查看(过去 30 天)
KA
KA 2015-11-11
评论: KA 2015-11-18
I am a novice at MATLAB and want to write a script that will involve several steps as follows:
1) Define two different vectors (can call them v-left, v-right) where a number is assigned to different letters of the alphabet. Say 1 – 26 for v-left and 27 – 52 for v-right.
2) Then write a string such as =’zxcvbnm’.
3) Have the script read the string at two positions starting at (1,3) i.e. (z,c).
4) Find the value for each letter as defined by v-left and v-right with the 1st letter in the pair (z) assigned to (v-left) and the 2nd letter in the pair (c) assigned to (v-right).
5) Apply a function to each value (e.g. log) and then average the two values.
6) Loop around and repeat the process but with each position in the string both increased by +1.
7) Repeat steps 3 -6 until the loop reaches the positions (length -2,length i.e. (b,m) in this instance)
8) Find the sum of all the values for each loop and display it.
Advice is very welcome. I may have to break this down a bit and ask in chunks.
  3 个评论
Stephen23
Stephen23 2015-11-16
编辑:Stephen23 2015-11-16
You will learn best when you actually try something. Don't be afraid of making mistakes: start MATLAB and experiment. Use your favorite internet search engine to locate the appropriate documentation or advice on how to code each of those steps. The more you attempt and the more that you try the more you will learn.
To get started you should work through these tutorials:
And read this:
KA
KA 2015-11-18
Hi thank you both. I am trying a different approach now, think this approach was flawed from the outset.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by