how do I do this in matlab? I have been trying C2M 3 0.16 0064 00255 01024 00016
ID: 2074664 • Letter: H
Question
how do I do this in matlab?
I have been trying
Explanation / Answer
Since there was a technical error in uploading the images, I was not able to upload the matlab code or results image. Therefore I have inserted code in written format.
Matlab code::::
function [A,Sum_A] = Chegg_Problem
x = [0:0.4:6]'; %% Defines x vector (column vector)
y = [0,3,4.5,5.8,5.9,5.8,6.2,7.4,9.6,15.6,20.7,26.7,31.1,35.6,39.3,41.5]'; %% Defines y vector (column vector)
C = vpa(x.*x,4); %% C = x^2
D = vpa(C.*x,5); %% D = x^3
E = vpa(C.*C,6); %% E = x^4
F = vpa(C.*D,6); %% F = x^5
G = vpa(D.*E,6); %% G = x^7
H = vpa(E.*E,7); %% H = x^8
I = vpa(x.*y,5); %% I = x*y
J = vpa(C.*y,6); %% J = x^2*y
K = vpa(D.*y,6); %% K = x^3*y
L = vpa(E.*y,6); %% L = x^4*y
M = vpa(D.*D,6); %% J = x^6
consolidated_mat=[x y C D E F G H I J K L M]; %% consolidated_mat represents all the consolidated matrices
A=vpa(consolidated_mat,7); %% A represents consolidated matrix in 7 decimals
Sum_A=vpa(sum(A),7); %% Sum_A represents sum of individual matrices i.e. x to M
end
To run the program, in the command window type:::
[A,Sum_A]=Chegg_Problem
Result will be:::::
A =
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0.4, 3.0, 0.16, 0.064, 0.0256, 0.01024, 0.0016384, 0.00065536, 1.2, 0.48, 0.192, 0.0768, 0.004096]
[ 0.8, 4.5, 0.64, 0.512, 0.4096, 0.32768, 0.2097152, 0.1677722, 3.6, 2.88, 2.304, 1.8432, 0.262144]
[ 1.2, 5.8, 1.44, 1.728, 2.0736, 2.48832, 3.583181, 4.299817, 6.96, 8.352, 10.0224, 12.02688, 2.985984]
[ 1.6, 5.9, 2.56, 4.096, 6.5536, 10.48576, 26.84355, 42.94967, 9.44, 15.104, 24.1664, 38.66624, 16.77722]
[ 2.0, 5.8, 4.0, 8.0, 16.0, 32.0, 128.0, 256.0, 11.6, 23.2, 46.4, 92.8, 64.0]
[ 2.4, 6.2, 5.76, 13.824, 33.1776, 79.62624, 458.6471, 1100.753, 14.88, 35.712, 85.7088, 205.7011, 191.103]
[ 2.8, 7.4, 7.84, 21.952, 61.4656, 172.1037, 1349.293, 3778.02, 20.72, 58.016, 162.4448, 454.8454, 481.8903]
[ 3.2, 9.6, 10.24, 32.768, 104.8576, 335.5443, 3435.974, 10995.12, 30.72, 98.304, 314.5728, 1006.633, 1073.742]
[ 3.6, 15.6, 12.96, 46.656, 167.9616, 604.6618, 7836.416, 28211.1, 56.16, 202.176, 727.8336, 2620.201, 2176.782]
[ 4.0, 20.7, 16.0, 64.0, 256.0, 1024.0, 16384.0, 65536.0, 82.8, 331.2, 1324.8, 5299.2, 4096.0]
[ 4.4, 26.7, 19.36, 85.184, 374.8096, 1649.162, 31927.78, 140482.2, 117.48, 516.912, 2274.413, 10007.42, 7256.314]
[ 4.8, 31.1, 23.04, 110.592, 530.8416, 2548.04, 58706.83, 281792.8, 149.28, 716.544, 3439.411, 16509.17, 12230.59]
[ 5.2, 35.6, 27.04, 140.608, 731.1616, 3802.04, 102807.2, 534597.3, 185.12, 962.624, 5005.645, 26029.35, 19770.61]
[ 5.6, 39.3, 31.36, 175.616, 983.4496, 5507.318, 172709.5, 967173.1, 220.08, 1232.448, 6901.709, 38649.57, 30840.98]
[ 6.0, 41.5, 36.0, 216.0, 1296.0, 7776.0, 279936.0, 1679616.0, 249.0, 1494.0, 8964.0, 53784.0, 46656.0]
Sum_A =
[ 48.0, 258.7, 198.4, 921.6, 4564.787, 23543.81, 675710.2, 3713586.0, 1159.04, 5697.952, 29283.62, 154711.5, 124858.0]
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.