fichero bibliogràfico VVVV | Tradiciones | Enseñanza

Please download to get full document.

View again

All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
 0
 
  Question 1: Code: prompt = 'Enter a natural number\n'; N = input (prompt); A = 1:N; Sum = sum(A) Average = Sum/N B = A .* A; SumOfSquares = sum(B) C = A.^0.5; SumOfSquareRoots = sum(C) Input: 51 Output: Sum = 1326 Average = 26 SumOfSquares = 45526 SumOfSquareRoots = 246.1772 Question 2: Code: A = rand (10); smallest = A(1); largest = A(1); for i=1:10 if (smallest A(i)) smallest = A(i); end end for i=1:10 if (largest
Share
Transcript
  Question 1: Code: prompt = 'Enter a natural number\n'; N = input (prompt);  A = 1:N; Sum = sum(A)  Average = Sum/N B = A .* A; SumOfSquares = sum(B) C = A.^0.5; SumOfSquareRoots = sum(C) Input:  51 Output: Sum = 1326  Average = 26 SumOfSquares = 45526 SumOfSquareRoots = 246.1772 Question 2: Code:   A = rand (10); smallest = A(1); largest = A(1); for i=1:10 if (smallest>A(i)) smallest = A(i); end end for i=1:10 if (largest<A(i)) largest = A(i); end end fprintf('The smallest number is %f\n',smallest) fprintf('The largest number is %f\n',largest)  Input:  A = 0.814723686 0.157613082 0.655740699 0.706046088 0.43874436 0.276025077 0.751267059 0.840717256 0.351659507 0.075854290.905791937 0.970592782 0.035711679 0.031832846 0.381558457 0.679702677 0.255095115 0.254282179 0.830828628 0.0539501190.126986816 0.957166948 0.849129306 0.276922985 0.765516788 0.655098004 0.505957052 0.814284826 0.585264091 0.5307975530.913375856 0.485375649 0.933993248 0.046171391 0.795199901 0.162611735 0.699076723 0.243524969 0.549723608 0.779167230.632359246 0.800280469 0.678735155 0.097131781 0.186872605 0.118997682 0.890903253 0.929263623 0.917193664 0.9340106840.097540405 0.141886339 0.757740131 0.823457828 0.489764396 0.498364052 0.959291425 0.349983766 0.285839019 0.1299062080.278498219 0.421761283 0.743132468 0.694828623 0.445586201 0.959743959 0.54721553 0.19659525 0.757200229 0.5688236610.546881519 0.915735525 0.39222702 0.31709948 0.64631301 0.340385727 0.138624443 0.251083858 0.753729094 0.4693906410.957506835 0.79220733 0.65547789 0.950222049 0.709364831 0.585267751 0.149294006 0.616044676 0.380445847 0.011902070.964888535 0.959492426 0.171186688 0.034446081 0.754686682 0.223811939 0.257508254 0.473288849 0.567821641 0.337122644   Output: The smallest number is 0.097540 The largest number is 0.964889 Question 3: Code: prompt = 'Enter a natural number\n'; N = input (prompt); a=0; for i=1:N if (rem(N,i)==0) a=a+1; end end if(a==2) fprintf('%d is a prime number\n',N) else fprintf('%d is a composite number\n',N) end Input: Enter a natural number 45 Output: 45 is a composite number Input: Enter a natural number 97 Output:  97 is a prime number Question 4: Code:   A = rand(5) B = rand(5) addition = A+B subtraction = A-B multiplication = A*B Input:  A= 0.417267069 0.489252638 0.780252068 0.131973293 0.2347799130.04965443 0.33771941 0.389738837 0.942050591 0.3531585710.90271611 0.900053846 0.241691286 0.95613454 0.821194040.94478719 0.369246781 0.403912146 0.575208595 0.0154034380.490864092 0.111202755 0.096454525 0.059779543 0.043023802  B= Output:  Addition= 0.586257099 1.036261531 0.963763224 1.061359264 0.5411293850.698769905 0.634040215 0.758223433 1.717763269 0.8616672271.634438496 1.644746653 0.867309847 1.442926173 1.3319656041.592533153 0.558201796 1.184139581 1.011067184 0.8330311460.941787799 0.797978189 0.177580294 0.506563292 0.837855219  Subtraction= 0.24827704 -0.057756254 0.596740913 -0.797412678 -0.071569559-0.599461045 0.041398604 0.02125424 0.166337912 -0.1553500840.170993724 0.155361039 -0.383927275 0.469342908 0.3104224760.297041227 0.180291766 -0.37631529 0.139350006 -0.8022242710.039940386 -0.575572678 0.015328756 -0.387004206 -0.751807615  Multiplication= 0.168990029 0.547008892 0.183511156 0.929385971 0.3063494720.649115475 0.296320806 0.368484596 0.775712679 0.5085086550.731722386 0.744692807 0.625618561 0.486791632 0.5107715640.647745963 0.188955015 0.780227435 0.435858589 0.8176277080.450923706 0.686775433 0.081125769 0.446783749 0.794831417  1.150376334 1.140450728 0.867011284 1.309559356 1.0696647891.282247669 0.838016225 1.141048369 1.066229315 1.436960561.903267975 1.685126492 1.461143407 2.438443768 2.2921537271.074429794 1.046280219 1.012178818 1.618714034 1.1660567010.283834912 0.414131039 0.241531259 0.634694607 0.339263828   Question 5: Code:  d2r = @(x) (x*pi/180); r2d = @(x) (x*180/pi); sys1 = [0.95 125 ; 0.0003 0.95] .* exp(j*d2r([1 75 ; 89 1])); sys2 = [0.94 85 ; 0.0005 0.94] .* exp(j*d2r([1.5 70 ; 90.1 1.5])); sys = sys1 * sys2;  A = [abs(sys(1,1)) r2d(angle(sys(1,1)))] B = [abs(sys(1,2)) r2d(angle(sys(1,2)))] C = [abs(sys(2,1)) r2d(angle(sys(2,1)))] D = [abs(sys(2,2)) r2d(angle(sys(2,2)))] Output:  A = 0.8336 3.7848 B = 198.0295 74.2602 C = 0.0008 90.8765 D = 0.8697 3.1699 Question 6: Code:  format longg z = 0.1 + j*0.4; y = j*3*10^(-6); l = 250; z_and_y = [z,y]; nominal = z_and_y .* 250 gamma = (y*z)^0.5; equivalent = [nominal(1,1)*sinh(gamma*250)/(gamma*250) nominal(1,2)*tanh(gamma*250/2)/(gamma*250/2) Output: Nominal =
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks
SAVE OUR EARTH

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!

x