ProductsLogo
LogoStudy Documents
LogoAI Grader
LogoAI Answer
LogoAI Code Checker
LogoPlagiarism Checker
LogoAI Paraphraser
LogoAI Quiz
LogoAI Detector
PricingBlogAbout Us
logo

Desklib - Online Library for Study Material with Solved Assignments, Essays, Dissertations

Verified

Added on  2023/06/09

|7
|541
|138
AI Summary
This page contains MATLAB code for various mathematical problems such as currency exchange, prime numbers, perfect numbers, Armstrong numbers, and graphs for x, y, and z. The code is provided for computational mathematics and computer architecture. No specific subject, course code, or college/university is mentioned.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Running Head: COMPUTATIONAL MATHEMATICS AND COMPUTER ARCHITECTURE
0
COMPUTATIONAL MATHEMATICS AND COMPUTER ARCHITECTURE

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
COMPUTATIONAL MATHEMATICS AND COMPUTER ARCHITECTURE
1
Currency Exchange
MATLAB Code
clc;
clear all;
close all;
toGBP = 0.56; toEuro = 0.64; toUsd = 0.72;
SGD = (1:25)';
USD = SGD.*toUsd;
EURO = SGD.*toEuro;
GBP = SGD.*toGBP;
data = table(SGD, USD, GBP, EURO);
disp(data)
Output
Document Page
COMPUTATIONAL MATHEMATICS AND COMPUTER ARCHITECTURE
2
Prime Number
MATLAB Code
clc;
clear all;
close all;
x1 =input('Enter first value = ');
x2 =input('Enter second value = ');
i = x1:x2 ;
p = isprime(i);
disp('prime numbers are =');
i(p)
Output
Perfect number
MATLAB Code
clc;
clear all;
Document Page
COMPUTATIONAL MATHEMATICS AND COMPUTER ARCHITECTURE
3
x1 =input('Enter first value ');
x2 =input('Enter second value ');
perfect = zeros(1,x2);
for n = x1:x2
if true
% code
end
test = 1:n-1;
if (sum(test(mod(n,test) == 0)) == n)
perfect(n) = n;
end
end
perfect(perfect == 0) = []
Output
Armstrong Number
MATLAB Code
clc;

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
COMPUTATIONAL MATHEMATICS AND COMPUTER ARCHITECTURE
4
x1 = input('Please input the first number: \n');
x2 = input('Please input the second number: \n');
for (value = x1:x2)
numstr = num2str(value);
i = 0;
for (digit = 1:length(numstr))
digitcube = str2num(numstr(digit)) ^ 3;
i = i + digitcube;
end
if (i == value)
fprintf('%d is an armstrong number. \n', value)
end
end
Output
Graph for x, y, and z
MATLAB Code
clc;
clear all;
x = 0:pi/100:20*pi;
y = x.*sin(x);
z = x.*cos(x);
Document Page
COMPUTATIONAL MATHEMATICS AND COMPUTER ARCHITECTURE
5
figure
plot(x,y)
xlabel('Axis for X');
ylabel('Axis for Y');
title('Graph in X-Y direction');
figure
polar(x,z)
xlabel('Axis for X');
ylabel('Axis for Z');
title('Graph in X-Z direction');
figure
plot(x,y,z)
xlabel('Axis for X');
ylabel('Axis for Y');
zlabel('Axis for Z');
title('Graph in X,Y,Z direction');
For x-y
Document Page
COMPUTATIONAL MATHEMATICS AND COMPUTER ARCHITECTURE
6
For x-z
For X, Y, and Z
1 out of 7
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]