Plot "CB" on a complex plane, rewriting this MatLab program: % Transform Initials % What…
- User
Plot "CB" on a complex plane, rewriting this MatLab program:
% Transform Initials % What this MATLAB script does: % 1) Plots my initials using scatter() in the complex plane. % 2) Transforms initials using addition/multiplication of complex numbers % 3) get creative? %% initialize initials clear all % never not do this! % ----------------------------------------- % x= 012345678901234567890 % y=6 **** ********* % 5 * ** * % 4 * * * % 3 * * * * % 41 pts total (by counting!) % 2 * * * * % 1 * ** ** * % 0 **** *** % x= 012345678901234567890 % ----------------------------------------- manually enter the coordinates npts = 41; Zo = zeros(1,npts); % preallocate the Zo array % ------------------------- Zo( 1) = 0 + 1i0; Zo( 2) = 1 + 1i0; Zo( 3) = 2 + 1i0; Zo( 4) = 3.2+ 1i0.2; % ( 3,0) --> ( 3.2,0.2) modified after initial tests Zo( 5) = 13.2+1i0.2; % (13,0) --> (13.2,0.2) modified after initial tests Zo( 6) = 14.1+1i0.1; % (14,0) --> (14.1,0.1) modified after initial tests Zo( 7) = 15 + 1i0; % ------------------------- Zo( 8) = 0 + 1i1; Zo( 9) = 4 + 1i0.5; % ( 4,1) --> ( 4,0.5) modified after initial tests Zo(10) = 5 + 1i1; Zo(11) = 11 + 1i1; Zo(12) = 12 + 1i0.5; % (12,1) --> (12,0.5) modified after initial tests Zo(13) = 15 + 1i1; % ------------------------- Zo(14) = 0 + 1i2; Zo(15) = 6 + 1i2; Zo(16) = 10 + 1i2; Zo(17) = 15 + 1i2; % ------------------------- Zo(18) = 0 + 1i3; Zo(19) = 6 + 1i3; Zo(20) = 10 + 1i3; Zo(21) = 15 + 1i3; % ------------------------- Zo(22) = 0 + 1i4; Zo(23) = 6 + 1i4; Zo(24) = 15 + 1i4; % ------------------------- Zo(25) = 0 + 1i5; Zo(26) = 5 + 1i5.5; % (5,5) --> (5,5.5) modified after initial tests Zo(27) = 6 + 1i5; Zo(28) = 15 + 1i5; % ------------------------- Zo(29) = 0 + 1i6; Zo(30) = 1 + 1i6; Zo(31) = 2 + 1i6; Zo(32) = 3.2+ 1i5.8; % (3,6) --> (3.2,5.8) modified after initial tests Zo(33) = 11 + 1i6; Zo(34) = 12 + 1i6; Zo(35) = 13 + 1i6; Zo(36) = 14 + 1i6; Zo(37) = 15 + 1i6; Zo(38) = 16 + 1i6; Zo(39) = 17 + 1i6; Zo(40) = 18 + 1i6; Zo(41) = 19 + 1i6; % ---------------------------------------------- check my inputed initials figure(1); clf; scatter(real(Zo),imag(Zo),75,'blue','filled'); figure(1); %error('stop here for now'); %% calculate center of mass and translate initials % ---------------------------- method 1 %xCM = mean(real(Zo)); %yCM = mean(imag(Zo)); %Zo = Zo - (xCM + 1iyCM); % ---------------------------- method 2 zCM = mean(Zo); % <= real & imaginary components act as a 2D vector Zo = Zo - zCM; % --------------------------------------------- check my centered initials figure(1); clf; axis equal % optional scatter(real(Zo),imag(Zo),75,'blue','filled'); figure(1); % --------------------------------------------- setting limits is optional %{ xMIN = min(real(Zo)); xMAX = max(real(Zo)); yMIN = min(imag(Zo)); yMAX = max(imag(Zo)); xMIN = xMIN - 0.5; xMAX = xMAX + 0.5; yMIN = yMIN - 0.5; yMAX = yMAX + 0.5; xlim( [xMIN,xMAX]); ylim( [yMIN,yMAX]); %} %error('stop here for now'); %% do translations for i=1:5 dZ = input('enter dZ for translation: '); Znew = Zo + dZ; figure(1); clf; scatter(real(Zo),imag(Zo),100,[0.85,0.85,0.85],'filled'); hold on; scatter(real(Znew),imag(Znew),100,'blue','filled'); figure(1); end %% do rotations %{ for i=1:5 phi = input('enter phi for rotations (in degrees): '); phi = piphi); Znew = Zrotexp(iphi)'); R = input('enter R for magnitude of Z: '); phi = input('enter phi for rotations (in degrees): '); phi = piexp(1iZo; figure(1); clf; scatter(real(Zo),imag(Zo),100,[0.85,0.85,0.85],'filled'); hold on; scatter(real(Znew),imag(Znew),100,'blue','filled'); figure(1); end %}
- Assistant
- User
Write a MatLab program that plots “CB” on a complex plane using the scatter() function
- Assistant
% Plot "CB" on a complex plane
% Define the complex numbers representing the initials "C" and "B" C = [0 + 1i0, 1 + 1i0, 2 + 1i0, 3.2 + 1i0.2, 13.2 + 1i0.2, ... 14.1 + 1i0.1, 15 + 1i0, 0 + 1i1, 4 + 1i0.5, 5 + 1i1, ... 11 + 1i1, 12 + 1i0.5, 15 + 1i1, 0 + 1i2, 6 + 1i2, ... 10 + 1i2, 15 + 1i2, 0 + 1i3, 6 + 1i3, 10 + 1i3, ... 15 + 1i3, 0 + 1i4, 6 + 1i4, 15 + 1i4, 0 + 1i5, ... 5 + 1i5.5, 6 + 1i5, 15 + 1i5, 0 + 1i6, 1 + 1i6, ... 2 + 1i6, 3.2 + 1i5.8, 11 + 1i6, 12 + 1i6, 13 + 1i6, ... 14 + 1i6, 15 + 1i6, 16 + 1i6, 17 + 1i6, 18 + 1i6, 19 + 1i*6];
B = [0 + 1i0, 1 + 1i0, 2 + 1i0, 0 + 1i6, 1 + 1i6, ... 2 + 1i6, 1 + 1i3, 2 + 1i3, 3 + 1i3, 4 + 1i3, ... 5 + 1i3, 5 + 1i2.5, 3 + 1i2.5, 2 + 1i2.5, 1 + 1i2.5, ... 1 + 1i2, 2 + 1i2, 8 + 1i3, ... 7 + 1i3, 0 + 1i0];