HELP PLEASE!! How do I print matlab "1:5 multiply increases each line"
Show older comments
This is my code
clc
fprintf (' SGD USD GBP EURO \n')
for (x= 1 : 5)
USD = 0.69 *2;
GBP = 0.49 *2;
EURO = 0.64 *2;
fprintf (' \n %d %.2f %.2f %.2f ' ,SGD ,USD ,GBP ,EURO);
end
My results
SGD USD GBP EURO
1 1.38 0.98 1.28
1 1.38 0.98 1.28
1 1.38 0.98 1.28
1 1.38 0.98 1.28
1 1.38 0.98 1.28 >>
I want the 2nd line to multiple by two, the thrid line to multiple by three... so on and so fourth...
Accepted Answer
More Answers (1)
C.J. Harris
on 18 Jan 2016
Do you mean like this?
clc
fprintf(' SGD USD GBP EURO \n')
for x= 1 : 5
USD = 0.69 * 2 * x;
GBP = 0.49 * 2 * x;
EURO = 0.64 * 2 * x;
SGD = x;
fprintf (' \n %d %.2f %.2f %.2f ' ,SGD ,USD ,GBP ,EURO);
end
Result:
SGD USD GBP EURO
1 1.38 0.98 1.28
2 2.76 1.96 2.56
3 4.14 2.94 3.84
4 5.52 3.92 5.12
5 6.90 4.90 6.40
1 Comment
Ken kaneki
on 18 Jan 2016
Categories
Find more on Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!