Category Archives: Uncategorized

brownfox

Writing Impositions in Matlab

Writing Impositions in Matlab

This post is for students who do not do their homework (like me when I was in school) and are punished with writing impositions. The imposition would usually be writing something like a very long statement with no meaning several times. Like back in my school days, when we were told to write them on paper using a pen or pencil. But these days students and truants are asked (ordered!) to write them in a word-processing software. Well, we can think of using the classic trick of Ctrl+C and Ctrl+V, but it depends on the imposition type, right!

Like for say here, we are asked to write this statement :

“The quick brown fox jumps over the lazy dog”.

And the teacher asks you to change every vowel with its preceding vowel in each iteration.That would mean , in my first statement, a is replaced to e, e is replaced by i, i is replaced by o, o is replaced by u, and u is replaced by a. In subsequent iterations, the replaced vowels are replaced by their preceding vowel. And this has to be done say 100 times. (Quite a tough punishment!). This case can not be done in MS Word or any other word processor, so the student has to do type this manually each time or just do his homework instead.

However, good news! I have a Matlab code for you, which will do it for you however number of times you want to write. In the end, all you have to do copy the final output to a word processor  and get the print. The code is as simple it can be without using any library functions so that people with no knowledge about Matlab can still use, because then it is just English to understand.

You can get the code here, and use an online compiler to run it .

Download code here:

 

 

datasync

Data syncing and backUP

When we look around us , we are surrounded by data and a lot of information. But in this post I will not be talking about those objects (as they are called in object oriented programming). In this data refers to all the qualitative and quantitative set of information and variables we have stored in our computer. These data be it just collected, reported or even analysed are very crucial for every one. Every individual encounters different type of data. This page will classify different types of data for interested readers.

This post focuses on data back up and syncing. In simple words, it is the act of replicating data between two storage units, but the storage needs to be mirrored. That means change to one will be reflected to the other and vice versa. The advantage of this is that it saves a lot of time than the general copy pasting, and of course it is the ability to preview the changes before they are actually made.

For syncing there are various software in the market, some commercial and some open source applications.  Personally ,I use SyncToy, and have described the process to sync in this post. The good things about this software is it is a freeware and it has a very simple GUI to get the work done.

So here we go.

  1. Install the SyncToy software by downloading it from here.
  2. Once installed, open up the application.
  3. On the window that pops up, click on Create New Folder Pair.
  4. Now choose the folders that you want to sync. Left is the source folder path, Right is the target source folder path.
  5. Click NEXT.
  6.  The next window that follows asks about the type of sync, viz;
    Synchronize: Updates files both ways…keeping changes like renames, deletions and edits to either folder contents the same between the two.
    Echo: New and updated files are copied left to right. Renames and deletes on the left are repeated on the right.
    Contribute: New and updated files are copied left to right. Renames on the left are repeated on the right. No deletions.
  7.  I will recommend using the Contribute option.
  8.  After that, name your syncing action. Choose a suitable name in case you are syncing between different target sources. Click FINISH
  9. On the next window, click RUN, to see the software syncing your data from the source path to the target path.
  10. Once done, click CLOSE to see the report of syncing
  11. To schedule the syncing automatically,  go to Task Scheduler option in windows 7.
  12. Click on Create basic Task
  13. Next type a little name and description to the task like ” DataSYNC SyncToy”
  14.  Go to the trigger option, and select the frequency of syncing up to your convenience.
  15. In the Action tab of the window,  type “C:\Program Files\SyncToy2.1\SyncToy.exe” where it asks for Program/Script.
  16. In the add argument section, type -R
  17. Click Finish to get things done.
  18. Have it a go !
tc-turbo-c-software-interface

Guide to good programming in Matlab

Computational Physics by using Matlab

Computational physics can be regarded as an amalgamation of physics with mathematics and computer science. Computers these days have changed the way physics (and all sciences) is done, and computational physics is now widely accepted as an equally valid approach to Physics after Experimental and Theoretical approach.

Matlab is one of the nicest platform to do these physics and has been gaining a lot of popularity in problem solving  these days owing to its visibility and seamless integration feature. You can read more about Matlab here:

Some recommended books for Matlab are:

But Matlab as a platform is really colossal and like and ocean, so we need to be specific about the reason we are using Matlab .

Guide to Good programming:

If it is asked; What are the most important characteristics of a good program,or what do you mean by a good program?

Many people or mostly all will say efficiency and speed. Efficiency can have more synonyms like reliability, accuracy, perfectness etc.  Yes indeed that’s true not very true though. Efficiency and speed are really crucial characteristics of a program but they do not define a program to be a good program or a bad program.

 

report-card-pic

A program that is not efficient or accurate is of not much value , yet it still can be used if we understand the limitation of the program or what contain the accuracy of the code. We need to be the gentle and caring teacher who helps its pupils to understand the lessons. And for the speed; what matters is how long it takes to solve the problem and not how long to execute the program. So the speed can sometimes be traded for more accuracy (at least for experimental physics in which you use Matlab to talk to instruments and order them to solve your work)

Q: So, what is then the most important characteristic of a good program ?

Ans:  It is the clarity of the code that is the most or very crucial aspect of the code.  If its not clear what is the code doing then it is not a good code. If the code does not clearly describe the logic and algorithm of how it is doing our work, then it is not a good code. Unless you are in the receiving end of the code and believe in Data abstraction ideology.

On the other hand, if a code is clear and describes the use of each module, variables, algorithm then we are more likely to understand what is is intended to do. If or when there is an error, we can then very easily cure it as we understand the code, because of its clarity.

A standard problem solving approach for any problem or code is to break the code into smaller chunks called modules. This gives a better understanding of the total problem.This aspect is called as top-down design by physicists.

Capture

Another way to enhance the clarity of a code is to use valid variable names. Imagine reading a computer code asking to solve and integration of sin x over some space, and in the code you encounter a variable name as win32. What sense would  that make?  So employ using valid variable names and also make sure that the code does not have several variables doing the same operation. Try to extract maximum information and utilization from one single variable before it is cloned for some operations which can not be avoided.

This post is all about a basic tutorial of how to code in any programming platform. So start constructing some nice codes.

mathematical operations

Faster multiplication using lines

Faster multiplication using lines

Mathematical operations like addition, subtraction, multiplication, division are the basic operations that people use in their daily activities. Be it the school going children, the shopkeeper, scientists, academicians; everyone is bonded together at least by these mathematical operations.

One such mathematical operator (or operation) is Multiplication which basically means adding numbers together n times . It is donated by a cross symbol or a * operator.

This operation has got its own historical backgrounds, with Babylonian, Egyptians, Indians  (Vedic-multiplication) had devised different methods to perform this multiple copies (or multiplication) of a number.

 

In this post, a new easier method of multiplication is discussed, where the multiplication of numbers are represented by sets of parallel lines in different directions and counting the number of intersections of each set of parallel lines with the other set of parallel lines.

Faster multiplication using lines

So for example I ask you to multiply 12 *14. You can use a calculator or do it manually, to get the result as 168. But what if I tell you there’s another easier manual method to find the result which is much more easier and takes less time as well. You do not have to worry about wrong results as well, because the method is simple. The only con is this method is that you need to do it on a paper and cannot perform it mentally.

So lets see how it is done, before we move on to tougher problems.

We have been asked to multiply 12 to 14 or (12 *14)

Algorithm
  • For the digit 12  draw one line on one (1) edge of the paper and 2 lines parallel to this lines at the other edge of the paper.
  • For 14, similarly draw one (1) line on the bottom edge of the paper and , 4 lines on the opposite top edge of the paper parallel.
  • Divide the pattern into segments as shown in the figure: the left segment, the center segment and the right segment.
  • Now count the number of intersection of these lines in each segment. Start from the right segment ( right with respect to you)
  • Note the number of intersections of each segment.
  • if the number of intersection is more than 9, retain the value at one’s place in that segment and borrow the value at tenth’s place to the other segment.
  • Add the number of counts in that segment to the carry on number from the previous segment.
  • Once you have done this, your result is the number from the right segment to the left segment.
  • That’s it, some illustrations will help you understand the algorithm.
Multiplying illustration 1

Multiplying illustration 1

So give this method a try and try to solve for 3 digit multiplication

More illustrations:
Illustration 2

Illustration 2

 

Illustration 3

Illustration 3

 

gravity

The Anisotropy of Physics along linguistics

The Anisotropy of Physics along linguistics

The relationship between the distantly related subjects/disciplines: “Physics and Linguistics” is fascinating and charismatic. On one side, physics formulates principles and theories to describe the “real world“, and on the other side linguistics demonstrates us with tools to describe the cognitive ideas and perceive the “real physical world“.

Imagine a ferro-magnet made up of chunks of vowels and consonants instead of magnetic moments, an atom made of phonetics and not the obvious matter. A novel filled with theories and laws and the mathematics instead of subtle texts. These thoughts depict the everlasting but complementary relationship between this two disciplines, and all these years scientists, academicians, linguists have all worked together to describe the “real world with its physical nature“.

Newton and his law of Gravity.

The laws of universal gravity published by Issac Newton in The Principia in 1687, invited a  lot of discussions and clarifications bu esteemed researchers and scientists of that period. Apart from the physics, the law was also not easily understandable because of its “several linguistic issues”

The law of gravity which described “force of attraction”, between two bodies was metaphoric and also little less tangible to decipher. This law was greatly opposed by Gottfrid Leibniz, who advocated the idea of expressing reality in a logical and accurate way:”characeristica universalis“. He claimed that the law proposed by Newton was obscure and illogical and went on to describe it an as “occult quality“.

Newton was not cool with the criticism, however he admitted that the figurative presentations that are appropriate for the language “artificially adapted to the sense of the vulgar” do not have the precision of the mathematical concepts. He still as well did not reject the metaphor of attraction, nothing that it allows readers to understand the idea of gravity by referring it to their everyday life: “like apple from the tree because of gravity.

This moment in history is an remarkable example which show that the mutual symbiosis between the discoveries in physics and developments in linguistics. Physicists more or less consciously intervene in language in order to express the new discovery for the “real world“, which is widely discussed by linguists.

 

Featured image taken from: http://2.bp.blogspot.com/