reading strings and apying functions

1 view (last 30 days)
KA
KA on 11 Nov 2015
Commented: KA on 18 Nov 2015
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 Comments
Stephen23
Stephen23 on 16 Nov 2015
Edited: Stephen23 on 16 Nov 2015
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 on 18 Nov 2015
Hi thank you both. I am trying a different approach now, think this approach was flawed from the outset.

Sign in to comment.

Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!