Matlab help
%% 5.18 % According to Moore's law (an observation made in 1965 bt Gordab % Moore, a cofounder of Intel Corporation), the number of transistors % that would fit per square inch on a semiconductor integrated circuit % doubles approxmiately every 2 years. Although Moore's law is often % reported as predicting doubling every 18 months, this is incorrect. % A colleague of Moore took into that the fact that transistors % performance is also improving, and when combined with the increased % number number of transistors results in doubling of performance every % 18 months. The year 2005 was the 40th anniversary of the law. % Over the last 40 years, Moore's projection has been consistently met. % In 1965, the state-of-the-art technology allowed for % 30 transistors per square inch. Moore's law says that the % transistor density can be predicted by d(t) = 30(2^t/2), where % t is measured in years. % (a) Lettting t = 0 represent the year 1965 and t = 46 represent 2011, % use this model to calculate the predicted number of transisitors per % square inch for the 46 years from 1965 to 2011. Let t increase in % increments of 2 years. Display the results in a table with two % columns - one for the year and one for the number of transistor. t = 0:2:46; % time measured in years, from 1965 to 2011 d(t) = 30*(2.^(t ./ 2)); % transistor density function table = [t', [d(t)]']; % (b) Using the subplot feaure, plot the data in a linear x-y plot, a % semilog x plot, a semilog y plot, and a log-log plot. Be sure to % title the plots and label the axes. @jim_thompson5910
Okay so for some reason I can't get d(t) output.
to output*
the notation ` d(t) ` won't work. Let me think of how to fix that
I could just call it 'd' right?
yes you would say d = 30*(2.^(t ./ 2))
`table = [t', [d(t)]']` should be `table = [t', d']`
okay let me try that, sorry for the late reply I was doing something and almost forgot I was on opensudy
nice, it worked. Thanks!
so any suggestions for part b?
`Using the subplot feaure, plot the data in a linear x-y plot, a ` ` % semilog x plot, a semilog y plot, and a log-log plot.` so you'll have 4 separate plots * linear x-y plot * semilog x plot * semilog y plot * log-log plot
okay so linear, semilog, and log-log are commands?
let me do a bit of research
so a linear x-y plot is a normal plot you're familiar with http://www.mathworks.com/help/matlab/ref/plot.html where the x and y scale are incrementing by the same amount each time
I will figure it out.
http://www.mathworks.com/help/matlab/ref/semilogx.html makes the x scale a log scale instead of incrementing by the same amount, the scale looks like this https://upload.wikimedia.org/wikipedia/commons/8/83/LogLogPlot_of_Line.GIF notice how the x axis is going by 10^1, 10^2, 10^3, etc. It's not incrementing by the same amount each time. Instead, it's showing powers of 10
http://www.mathworks.com/help/matlab/ref/semilogy.html does the same thing, but this time to the y scale. The x scale is linear and finally http://www.mathworks.com/help/matlab/ref/loglog.html will make a log-log plot
a log-log plot is where both axis (x and y) are on a log scale
@jim_thompson5910 okay so I used the plot(x, y) it's not linear. it's exponential.
y values increase by a lot for every increase in x
plot(x,y) isn't referring to the shape of the curve you see it's referring to how the scales are set up if you increment by 10 each time, then the scale is a linear scale
you could have a nonlinear curve (eg: exponential curve) on a linear scale xy axis
okay that makes sense. I just wanted to double check to make sure my logic is correct.
hmm I wonder if there is a way to increase the values on x and y. What I mean is increase the size of the interval so the graph looks linear.
I think it's possible. If you adjust the scales, then it warps the shape. I think some cases you can turn a curve into a straight line (when going from normal linear scale to log scale)
I would have to increase my t value though. The end of your last comment how would you do that? (when going from normal linear scale to log scale)
one moment
okay I am working on the semilog x plot
% linear x-y plot subplot(2, 2, 1); y1 = log(t); semilog(t, y1); title('Linear x-y plot'); xlabel('X'); ylabel('Y'); http://www.mathworks.com/help/matlab/ref/semilogx.html
^^ that will give me a linear line if I use y1 = log(t) and semilogx(t, y1)
let me try it out
yes I'm getting a straight line as well
Would that be an appropriate answer to the first part of part (b)?
yes I think so. They just want to see the 4 plots
Okay awesome
is the semilog y plot going to look linear as well?
not for log(x) but it does for exp(x)
okay give me a sec I think I know what you are talking about
% linear x-y plot subplot(2, 2, 1); % subplot one y1 = log(t); % log function used to create linear line semilogx(t, y1); % semilog function title('Semilog x plot'); % title for subplot one xlabel('X'); ylabel('Y'); % x and y axis lables % semilog x plot subplot(2, 2, 2); semilogx(t, d); title('Semilog y plot'); xlabel('X'); ylabel('Y');
let me make my last subplot and I will paste my whole entire code here.
% (a) Lettting t = 0 represent the year 1965 and t = 46 represent 2011, % use this model to calculate the predicted number of transisitors per % square inch for the 46 years from 1965 to 2011. Let t increase in % increments of 2 years. Display the results in a table with two % columns - one for the year and one for the number of transistor. t = 0:2:46; % time measured in years, from 1965 to 2011 d = 30*(2.^(t ./ 2)); % transistor density function table = [t', d']; % table with year and number of transitors % (b) Using the subplot feaure, plot the data in a linear x-y plot, a % semilog x plot, a semilog y plot, and a log-log plot. Be sure to % title the plots and label the axes. % linear x-y plot subplot(2, 2, 1); % subplot one y1 = log(t); % log function used to create linear line semilogx(t, y1); % semilog function title('Semilog x plot'); % title for subplot one xlabel('X'); ylabel('Y'); % x and y axis lables % semilog x plot subplot(2, 2, 2); semilogx(t, d); title('Semilog x plot'); xlabel('X'); ylabel('Y'); % semilog y plot subplot(2, 2, 3); semilogy(t, d); title('Semilog y plot'); xlabel('X'); ylabel('Y'); % log-log plot subplot(2, 2, 4); loglog(t, d); title('Log-log plot'); xlabel('X'); ylabel('Y');
shouldn't `plot(t,y1)` be in there somewhere? towards the top of part b?
I see what you are saying. The code that creates the linear x-y plot doesn't need plot(t, y1)
% linear x-y plot subplot(2, 2, 1); % subplot one y1 = log(t); % log function used to create linear line semilogx(t, y1); % semilog function title('Semilog x plot'); % title for subplot one xlabel('X'); ylabel('Y'); % x and y axis lables
subplot(2, 2, 1); looks like it sets up an empty plot to fill it with something, but you forgot about the actual plot command for the linear x scale and linear y scale
% linear x-y plot subplot(2, 2, 1); % subplot one y1 = log(t); % log function used to create linear line semilogx(t, y1); % semilog function f plot(t, y1); title('Semilog x plot'); % title for subplot one xlabel('X'); ylabel('Y'); % x and y axis lables % semilog x plot subplot(2, 2, 2); semilogx(t, d); title('Semilog x plot'); xlabel('X'); ylabel('Y'); % semilog y plot subplot(2, 2, 3); semilogy(t, d); title('Semilog y plot'); xlabel('X'); ylabel('Y'); % log-log plot subplot(2, 2, 4); loglog(t, d); title('Log-log plot'); xlabel('X'); ylabel('Y'); okay how about now?
That doesn't give me a linear line though.
concave down graph
for some reason you have semilogx twice
I'd delete the first semilog to make plot come first
% linear x-y plot subplot(2, 2, 1); % subplot one plot(t, y1); % semilog function f title('Linear x-y plot'); % title for subplot one xlabel('X'); ylabel('Y'); % x and y axis lables % semilog x plot subplot(2, 2, 2); semilogx(t, d); title('Semilog x plot'); xlabel('X'); ylabel('Y'); % semilog y plot subplot(2, 2, 3); semilogy(t, d); title('Semilog y plot'); xlabel('X'); ylabel('Y'); % log-log plot subplot(2, 2, 4); loglog(t, d); title('Log-log plot'); xlabel('X'); ylabel('Y');
when I use plot(t, y1) though it's still concave down graph, not linear
much better and it should be curved. On a linear scale, log(x) looks like you would see in a previous algebra class. A curved line that is concave down
is it curve because we have large y values for every 1 increase in x?
I didn't use log(x) in subplot1
wait, I'm curious why you have y1 = log(t) for the plot but you use d for the other graphs
shouldn't it be `plot(t, d)` ?
yes it should be. That looks much better
i have another quick question. let me make a new thread
Join our real-time social learning platform and learn together with your friends!