reading strings and apying functions
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Stephen23
am 16 Nov. 2015
Bearbeitet: Stephen23
am 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:
Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!