필터 지우기
필터 지우기

Storing values from for loop and plotting

조회 수: 1 (최근 30일)
Benjamin Cowen
Benjamin Cowen 2016년 4월 20일
편집: Azzi Abdelmalek 2016년 4월 20일
I have a loop and I want to store the values when I plot. Needless to say this does not work. How Can I generate a plot for all values of T and Time_Years?
for T=15000000:500000:50000000
Chi_Rad = Chi_0 * Density_CGS^2 * T^(-3.5); % (1/cm)
Chi_Rad_SI = Chi_Rad*100; % (1/m)
Denominator = (16 * sigma * T^3)/(3*Chi_Rad_SI);
Numerator = Density_SI * (5/2) * (R_mass_SI/mu) * R_b^2;
Time_seconds = Numerator / Denominator;
Time_years = Time_seconds / (3.154 * 10^7)
plot(T,Time_years)
end

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 20일
편집: Azzi Abdelmalek 2016년 4월 20일
T1=15000000:500000:50000000
for k=1:numel(T1)
T=T1(k);
Chi_Rad = Chi_0 * Density_CGS^2 * T^(-3.5); % (1/cm)
Chi_Rad_SI = Chi_Rad*100; % (1/m)
Denominator = (16 * sigma * T^3)/(3*Chi_Rad_SI);
Numerator = Density_SI * (5/2) * (R_mass_SI/mu) * R_b^2;
Time_seconds = Numerator / Denominator;
Time_years(k) = Time_seconds / (3.154 * 10^7)
end
plot(T1,Time_years)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by