I'm trying to do this step function, the final goal is to plot Gabriel's cake. x goes from 0 to 8. f(x)=1/n if n<=x<n+1. I'm not sure how to do this. I'm guessing the if command but I'm not sure how to do it. Any help is appreciated. Thank You.
its just a step function, ignore the n i guess. when 1<=x<2 f(x)=1/1. when 2<=x<3, f(x)=1/2 and so on. x runs from 0 to 8 so when you plot x vs. y it steps down each integer. Walter posted a good article explaining it. http://www.maa.org/pubs/Calc_articles/ma044.pdf
What difference do you see between this plot and the plot I already gave the short formula for? Do you agree that this longer code implements the criteria for Gabriel's Cake? If there is no visible difference between the output of this code and the output of my earlier code, then are both wrong or do you agree that my earlier code was correct?
The code you just gave is correct. The previous code was a little different. Thank you I really appreciate it, huge help. I just have one more question. I'm using [x,y,z]cylinder(y) to make the shape and then plotting it with mesh(x,y,z). When I plot it, it makes all the axis 0-1 instead of x and y being one and z going from 0-8 (my original x values). Any idea how to get one of the axis to use my original x values? I get errors if i change anything. Is cylinder(y) the only way to do volumes of revolution?
What differences do you see between what you are looking for and what you get ? I do not have access to MATLAB itself at the moment, but when I plot in a different package, the result looks like what I would expect. Or is the problem merely with the end condition? Do you want it to end just _before_ 8, or right _at_ 8 (which would be 1/8), or do it want it to end just _before_ 9, or what ?
using the floor(x) you suggested is giving me a plot very similar to what i want but each level of it gets smaller and smaller at the same rate. whereas the step function i posted each level is smaller but the amount that its smaller is less every level. the first level or ring has a radius of 1. the next is half that (1/2). the next is a 1/3, and the next 1/4. The floor is giving me something that looks more like the first level is 1, the next is 1/2, then next is 1/4, the next is 1/8, ect. I can try to post pictures if that doesn't make sense.
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
Translated by
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.