my plot line is not showing line, how do i fix this?

disp ('fahrenheit(f) celcius(cel) kelvin(kelv) Reaction rate(react)')
for f=50:1:104
cel=(f-32)/1.8;
kelv=(f+459.67)/1.8;
A=10^11;
e=2.71828;
Ea=7.5*10^4;
Rt=8.314*kelv;
react=(A*e^(-Ea/Rt));
q=[f;cel;kelv;react];
fprintf('%8i %15.5f %15.5f %22.5f\n',q);
end
close all
x=linspace(-1000*3.14,1000*3.14);
y1=react;
y2=cel;
plot(x,y1,x,y2)

 Risposta accettata

The code needs a bit of tweaking, however the first problem is that ‘cel’ and ‘react’ need to be subscripted, and ‘q’ modified accordingly:
disp ('fahrenheit(f) celcius(cel) kelvin(kelv) Reaction rate(react)')
for f=50:1:104
cel(f)=(f-32)/1.8;
kelv=(f+459.67)/1.8;
A=1E+11;
e=2.71828;
Ea=7.5*10^4;
Rt=8.314*kelv;
react(f)=(A*exp(-Ea/Rt));
q(:,f)=[f;cel(f);kelv;react(f)];
% fprintf('%8i %15.5f %15.5f %22.5f\n',q);
end
close all
x=linspace(-1000*3.14,1000*3.14,f);
y1=react;
y2=cel;
plot(x,y1,x,y2)
I also changed the e^ to exp.

Più risposte (0)

Categorie

Prodotti

Release

R2020b

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by