Currency conversion using matlab script - i have no idea how to start with this

Write a MATLAB script to display currency conversion for US Dollar, British Pound, Euro with Singapore Dollar as the base Currency. Your output should show the equivalent values for USD, GBP, EURO for every Singapore dollar in increments of 1 dollar until 25 dollars.
Sample Output to be as follows:
SGD USD GBP EURO
1 - - -
2 - - -
3 - - -
..
..
25 - - -

Réponses (2)

Thorsten
Thorsten le 14 Sep 2015
Modifié(e) : Thorsten le 14 Sep 2015
SGD2X = [0.70991 0.23 5.3444 9.000]; % put the actual values here to convert from Singapore Dollars to USD, British Pound etc.
T = T = (1:25)'*SGD2X

4 commentaires

thanks for the quick answer, can you explain to me what does this line means?
T = cumsum(ones(25,1))*SGD2X
What does cumsum and ones mean? and 25,1?
And also, how can I display the output to appear like this?
SGD USD GBP EURO
1 - - -
2 - - -
3 - - -
..
..
25 - - -
I would have to use the matlab script editor, and use fprintf?
Thank you Walter,
I have problem getting it to work in script form.
There is no problem if I use the normal command window in matlab.
But it doesn't show anything in the command window while using script?
My script is as follows:
clc
SGD = [1 0.73 0.46 0.63];
x = cumsum(ones(25,1))*SGD;
fprintf ('SGD USD GBP EURO', x);
please advise thanks
The cumsum(ones(25,1)) just generates the numbers from 1 to 25. I replaced above with 1:25. ones and cumsum are basic matlab commands. You can find out about them using help.
To display the output you can use disp. Just add a column of the values 1:25 in front of T
disp('SGD USD GBP EURO')
disp([[1:25]' T])

Connectez-vous pour commenter.

Catégories

En savoir plus sur Enterprise Deployment with MATLAB Production Server dans Centre d'aide et File Exchange

Produits

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by