필터 지우기
필터 지우기

Line 21 giving me troubles

조회 수: 1 (최근 30일)
azaandria
azaandria 2021년 2월 7일
댓글: David Hill 2021년 2월 7일
Could someone help please? Having errors with line 21 for "Time".
%This program will calculate the approximate time for electrons to travel
% from cathode to anode of a rectifier tube.
%
clear
clc
%Get user input
min_V=input('Enter the min limit of accelerating voltage:');
max_V=input('Enter the max limit of accelerating voltage:');
r1=input('Enter the radius of the inner tube (cathode) in mm:');
r2=input('Enter the radius of the outer tube (anode) in mm:');
%
%
V=(min_V:1:max_V);
%Range of voltage 1-10, increments 1
z=log(r2./r1);
%Natural Logarithm of R2/R1
q=1.60206*10^-19;
%Charge of electron in coulombs
m=9.1083*10^-31;
%Mass of electron in kilograms
time=z*r1*(sqrt((2*m)/(q.*V)))*(1+(z/3)+(z^2/10)+(z^3/42)+(z^4/216));
%Time for electron to travel from cathode to anode (in sec)
%
%
%
%
%Display output as required
my_results=[V',time'];
disp(' ');
disp('Voltage Time');
disp('-------- ------');
disp('(volts) (seconds)');
disp(my_results);
%
%End of file

채택된 답변

David Hill
David Hill 2021년 2월 7일
편집: David Hill 2021년 2월 7일
time=z*r1*(sqrt((2*m)./(q*V)))*(1+(z/3)+(z^2/10)+(z^3/42)+(z^4/216));%just need ./ since V is an array
  댓글 수: 2
azaandria
azaandria 2021년 2월 7일
Thank you. That did help partially. But something is still wrong with my formula. Its calculating 0.00 seconds for every volt. I will review my calculations. Thanks!
Enter the min limit of accelerating voltage:
1
Enter the max limit of accelerating voltage:
10
Enter the radius of the inner tube (cathode) in mm:
2
Enter the radius of the outer tube (anode) in mm:
4
Voltage Time
-------- ------
(volts) (seconds)
1.0000 0.0000
2.0000 0.0000
3.0000 0.0000
4.0000 0.0000
5.0000 0.0000
6.0000 0.0000
7.0000 0.0000
8.0000 0.0000
9.0000 0.0000
10.0000 0.0000
David Hill
David Hill 2021년 2월 7일
It is working. Time is of the order of 10e-6, so the display is zero. Try:
plot(V,time);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by