how to plot graph?

2 views (last 30 days)
deep kandpal
deep kandpal on 12 Aug 2014
Answered: Andreas Goser on 14 Aug 2014
clear all
Na=6.022e23 ;
sigma_C=5.33; % b
sigma_water = 103.66%
S = 10^-24*[sigma_c sigma_water];
rho(1)=1.6; %carbon g/cm^3
rho(2)=1 ; %water g/cm^3
M = [12 18.015];
for i=1:2
sigma(i) = s(i)*rho(i)*Na/M(i);
end
x=linspace(0/15);
for j=1:2
for j=1:100
I(i,j)=exp(-sigma (j)*x(i));
end
end
figure
hold on
plot (x,I(:1),'K')
Plot (x,I(;2) , 'k:')
x lable ( 'distance(cm)')
y lable ('Fractional Intensity')
legend ('Graphite,' 'water')
  2 Comments
Andreas Goser
Andreas Goser on 12 Aug 2014
And your question is?
Andreas Goser
Andreas Goser on 14 Aug 2014
Are you a student in engineering or sciene? Then your really really need to learn such things. Not just because it is MATLAB. It is about programming.
Open this code in the MATLAB Editor and debug it. I will give you two sarting points as answer below.

Sign in to comment.

Answers (2)

Andreas Goser
Andreas Goser on 12 Aug 2014
Your code contains >5 small syntactic errors and typos. Please try to execute yourself line by line and make the necessary corrections starting with sigma_c vs sigma_C. Then post the code with the questio.
  1 Comment
deep kandpal
deep kandpal on 12 Aug 2014
i am new in matlab sir can you fixed it?

Sign in to comment.


Andreas Goser
Andreas Goser on 14 Aug 2014
First error example
Error: File: ....m Line: 20 Column: 12 Unexpected MATLAB expression.
This is
plot (x,I(:1),'K')
This is simply not existing syntax. Maybe you want to do:
plot (x,I(:,1),'K')
But nobody can fix this for you as nobody knows what you plan to do.
Next line: plot instead of plot. Mind case sensitivity.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!