MATLAB problem. Would like a detailed answer line by line. Write a MATLAB progra
ID: 2080258 • Letter: M
Question
MATLAB problem. Would like a detailed answer line by line.
Write a MATLAB program in a script file that determines the radius, r, of the largest sphere that can be inscribed inside a cone with base radius R and height h as, r = h/Squareroot 1 + (h/R)^2 + 1 For input the program asks the user to enter values for R and h. The program then calculates r rounded to the nearest tenth. For output the program displays the message: "The radius of the largest sphere that can be inscribed inside a cone with a base radius of XX in. and heights of XX in. is: XX in." where XX are the corresponding numerical values. Use the program to determine r for a cone with R - 8 in. and h - 22 in. Use fprintf () to display the output in f format with a field width of 5 and one decimal digit You can display your output in 2 or more lines using multiple fprintf ().Explanation / Answer
"Sean de " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <id3qkd$uo$1@fred.mathworks.com>...
> "Aimen " <ams107@ic.ac.uk> wrote in message <iclkol$mc9$1@fred.mathworks.com>...
> > "Sean de " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <icjhph$6id$1@fred.mathworks.com>...
> > > "Aimen " <ams107@ic.ac.uk> wrote in message <icjd3e$qi6$1@fred.mathworks.com>...
> > > > I need a 3d sphere of 1's in a cubic matrix of zeros. I cannot thing of how to do this
> > > >
> > > > Regards
> > >
> > > Use the formula for a sphere:
> > > %Sphere of 1s with radius 25 centered at 50,50,50 in a 100x100x100 zero matrix
> > > %%%
> > > %Engine
> > > [xx yy zz] = meshgrid(1:100,1:100,1:100);
> > > S = sqrt((xx-50).^2+(yy-50).^2+(zz-50).^2)<=25;
> > >
> > > %Visualize
> > > isosurface(S,0)
> > > %SCd
> > > %%%
> > Thank you for your help. However maybe i was not clear enough. i need to make a matrix of zero's with a sphere of 1's in the matrix.
> > i have started with a matrix of zero's by using:
> > A = zeros(L,L,L)
> > I will set radius of sphere. My biggest problem is that i am unable to use the vector equation you have sent as i cannot set an x, y and z axes in my 3d matrix of zero's. i need to use element positions i think to achieve this but dont know how
>
>
> What I gave you does EXACTLY what you have requested.
> If you look at S, you'll see that it is a 3d matrix, if you look at any slice where a sphere with radius 25 centered at (50, 50, 50) would be, you'll see the corresponding ones with everything else left as zeros.
Yes, you did. I apologise. When i wrote the message i was struggelling with meshgrid function. i realise now that it numbers locates the elements in a matrix in 3d space. thank you very much for your help and i apologise for not realising.
a minor question, if i wanted to set boundary conditions for the box, could i do this is a program file (.m file) or wwuld i need to create a model??
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.