how to plot graph?

1 次查看(过去 30 天)
deep kandpal
deep kandpal 2014-8-12
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 个评论
Andreas Goser
Andreas Goser 2014-8-12
And your question is?
Andreas Goser
Andreas Goser 2014-8-14
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.

请先登录,再进行评论。

回答(2 个)

Andreas Goser
Andreas Goser 2014-8-12
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.

Andreas Goser
Andreas Goser 2014-8-14
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.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by