I wanted to create two spheres that overlap each other in MATLAB. The image has my code and results. I only see one sphere in the results. Why is that? Can you give me the code that will create two overlaying spheres in one plot?

Elements Of Electromagnetics
7th Edition
ISBN:9780190698614
Author:Sadiku, Matthew N. O.
Publisher:Sadiku, Matthew N. O.
ChapterMA: Math Assessment
Section: Chapter Questions
Problem 1.1MA
icon
Related questions
Topic Video
Question

I wanted to create two spheres that overlap each other in MATLAB. The image has my code and results. I only see one sphere in the results. Why is that? Can you give me the code that will create two overlaying spheres in one plot?

clc;
clear all;
I = [0.3; 0.2; 0.4];
H = [0.03; 0.002; 0.004];
Trot = 0.0015;
a = sqrt(2*I(1) * Trot);
b = sqrt(2*I(2) *Trot);
c = sqrt(2*I(3) * Trot);
% Create the first sphere
[x1, y1, z1] = sphere;
x1 = a* x1 + H(1);
yl byl + H(2);
z1 cz1+ H(3);
% Create the second sphere
[x2, y2, z2] = sphere;
x2 = a* x2 + H(1);
y2 = b y2 + H(2);
z2 = cz2 + H(3);
% Plot both spheres
surf(x1, yl, z1, 'FaceAlpha', 0.5);
I hold on
surf(x2, y2, z2, 'FaceAlpha', 0.5);
axis equal
Figure 1
File Edit View Insert Tools Desktop Window Help
DE
0.03
0.02
0.01
0
-0.01
-0.02
-0.03
0.02
0
-0.02
0
0.02
0.04
0.06
x
N
Transcribed Image Text:clc; clear all; I = [0.3; 0.2; 0.4]; H = [0.03; 0.002; 0.004]; Trot = 0.0015; a = sqrt(2*I(1) * Trot); b = sqrt(2*I(2) *Trot); c = sqrt(2*I(3) * Trot); % Create the first sphere [x1, y1, z1] = sphere; x1 = a* x1 + H(1); yl byl + H(2); z1 cz1+ H(3); % Create the second sphere [x2, y2, z2] = sphere; x2 = a* x2 + H(1); y2 = b y2 + H(2); z2 = cz2 + H(3); % Plot both spheres surf(x1, yl, z1, 'FaceAlpha', 0.5); I hold on surf(x2, y2, z2, 'FaceAlpha', 0.5); axis equal Figure 1 File Edit View Insert Tools Desktop Window Help DE 0.03 0.02 0.01 0 -0.01 -0.02 -0.03 0.02 0 -0.02 0 0.02 0.04 0.06 x N
Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Fluid Statics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, mechanical-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Elements Of Electromagnetics
Elements Of Electromagnetics
Mechanical Engineering
ISBN:
9780190698614
Author:
Sadiku, Matthew N. O.
Publisher:
Oxford University Press
Mechanics of Materials (10th Edition)
Mechanics of Materials (10th Edition)
Mechanical Engineering
ISBN:
9780134319650
Author:
Russell C. Hibbeler
Publisher:
PEARSON
Thermodynamics: An Engineering Approach
Thermodynamics: An Engineering Approach
Mechanical Engineering
ISBN:
9781259822674
Author:
Yunus A. Cengel Dr., Michael A. Boles
Publisher:
McGraw-Hill Education
Control Systems Engineering
Control Systems Engineering
Mechanical Engineering
ISBN:
9781118170519
Author:
Norman S. Nise
Publisher:
WILEY
Mechanics of Materials (MindTap Course List)
Mechanics of Materials (MindTap Course List)
Mechanical Engineering
ISBN:
9781337093347
Author:
Barry J. Goodno, James M. Gere
Publisher:
Cengage Learning
Engineering Mechanics: Statics
Engineering Mechanics: Statics
Mechanical Engineering
ISBN:
9781118807330
Author:
James L. Meriam, L. G. Kraige, J. N. Bolton
Publisher:
WILEY