Ask your own question, for FREE!
Mathematics 21 Online
OpenStudy (raffle_snaffle):

Matlab help

OpenStudy (raffle_snaffle):

%% 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

OpenStudy (raffle_snaffle):

Okay so for some reason I can't get d(t) output.

OpenStudy (raffle_snaffle):

to output*

jimthompson5910 (jim_thompson5910):

the notation ` d(t) ` won't work. Let me think of how to fix that

OpenStudy (raffle_snaffle):

I could just call it 'd' right?

jimthompson5910 (jim_thompson5910):

yes you would say d = 30*(2.^(t ./ 2))

jimthompson5910 (jim_thompson5910):

`table = [t', [d(t)]']` should be `table = [t', d']`

OpenStudy (raffle_snaffle):

okay let me try that, sorry for the late reply I was doing something and almost forgot I was on opensudy

OpenStudy (raffle_snaffle):

nice, it worked. Thanks!

OpenStudy (raffle_snaffle):

so any suggestions for part b?

jimthompson5910 (jim_thompson5910):

`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

OpenStudy (raffle_snaffle):

okay so linear, semilog, and log-log are commands?

jimthompson5910 (jim_thompson5910):

let me do a bit of research

jimthompson5910 (jim_thompson5910):

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

OpenStudy (raffle_snaffle):

I will figure it out.

jimthompson5910 (jim_thompson5910):

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

jimthompson5910 (jim_thompson5910):

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

jimthompson5910 (jim_thompson5910):

a log-log plot is where both axis (x and y) are on a log scale

OpenStudy (raffle_snaffle):

@jim_thompson5910 okay so I used the plot(x, y) it's not linear. it's exponential.

OpenStudy (raffle_snaffle):

y values increase by a lot for every increase in x

jimthompson5910 (jim_thompson5910):

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

jimthompson5910 (jim_thompson5910):

you could have a nonlinear curve (eg: exponential curve) on a linear scale xy axis

OpenStudy (raffle_snaffle):

okay that makes sense. I just wanted to double check to make sure my logic is correct.

OpenStudy (raffle_snaffle):

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.

jimthompson5910 (jim_thompson5910):

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)

OpenStudy (raffle_snaffle):

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)

jimthompson5910 (jim_thompson5910):

one moment

OpenStudy (raffle_snaffle):

okay I am working on the semilog x plot

OpenStudy (raffle_snaffle):

% 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

OpenStudy (raffle_snaffle):

^^ that will give me a linear line if I use y1 = log(t) and semilogx(t, y1)

jimthompson5910 (jim_thompson5910):

let me try it out

jimthompson5910 (jim_thompson5910):

yes I'm getting a straight line as well

OpenStudy (raffle_snaffle):

Would that be an appropriate answer to the first part of part (b)?

jimthompson5910 (jim_thompson5910):

yes I think so. They just want to see the 4 plots

OpenStudy (raffle_snaffle):

Okay awesome

OpenStudy (raffle_snaffle):

is the semilog y plot going to look linear as well?

jimthompson5910 (jim_thompson5910):

not for log(x) but it does for exp(x)

OpenStudy (raffle_snaffle):

okay give me a sec I think I know what you are talking about

OpenStudy (raffle_snaffle):

% 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');

OpenStudy (raffle_snaffle):

let me make my last subplot and I will paste my whole entire code here.

OpenStudy (raffle_snaffle):

% (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');

jimthompson5910 (jim_thompson5910):

shouldn't `plot(t,y1)` be in there somewhere? towards the top of part b?

OpenStudy (raffle_snaffle):

I see what you are saying. The code that creates the linear x-y plot doesn't need plot(t, y1)

OpenStudy (raffle_snaffle):

% 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

jimthompson5910 (jim_thompson5910):

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

OpenStudy (raffle_snaffle):

% 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?

OpenStudy (raffle_snaffle):

That doesn't give me a linear line though.

OpenStudy (raffle_snaffle):

concave down graph

jimthompson5910 (jim_thompson5910):

for some reason you have semilogx twice

jimthompson5910 (jim_thompson5910):

I'd delete the first semilog to make plot come first

OpenStudy (raffle_snaffle):

% 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');

OpenStudy (raffle_snaffle):

when I use plot(t, y1) though it's still concave down graph, not linear

jimthompson5910 (jim_thompson5910):

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

OpenStudy (raffle_snaffle):

is it curve because we have large y values for every 1 increase in x?

OpenStudy (raffle_snaffle):

I didn't use log(x) in subplot1

jimthompson5910 (jim_thompson5910):

wait, I'm curious why you have y1 = log(t) for the plot but you use d for the other graphs

jimthompson5910 (jim_thompson5910):

shouldn't it be `plot(t, d)` ?

OpenStudy (raffle_snaffle):

yes it should be. That looks much better

OpenStudy (raffle_snaffle):

i have another quick question. let me make a new thread

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!