필터 지우기
필터 지우기

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에서 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