MATLAB Answers

How to combine table output in one table?

2 views (last 30 days)
Ajayan Rajendran
Ajayan Rajendran on 2 Sep 2021
Commented: Image Analyst on 2 Sep 2021
I used this coding , T=table(X,Ground_Level_Conc) .... The ouput is shown like this... How to make it in one table ?

Answers (3)

Image Analyst
Image Analyst on 2 Sep 2021
Not sure what the variables are but they need to be column vectors. So if you use (:) it should work
T=table(X(:), Ground_Level_Conc(:))
If that doesn't work show us what this says in the command window
whos X
whos Ground_Level_Conc
You can also attach those variables in a .mat file with the paperclip icon.

dpb
dpb on 2 Sep 2021
Hr=2;
u=11.5;
Qm=7973504;
X=[10:20];
sigma_y=0.22*X./sqrt(1+0.0001*X);
sigma_z=0.20*X;
Ground_Level_Conc=(Qm./(3.142*sigma_y.*sigma_z*u)).*exp((-1/2)*(Hr./sigma_z).^2);
plot(X,Ground_Level_Conc,'.')
xlabel('Downwind Distance (m)')
ylabel('Ground Level Concentration (mg/m3) ')
title('Dispersion Graph');
T=table(X,Ground_Level_Conc);
Use MATLAB array operations -- your assignment to T overwrites the variable every time

Image Analyst
Image Analyst on 2 Sep 2021
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
Hr = 2
u = 11.5
Qm = 7973504
prompt = 'Put Range of X value (m) :';
% X = input(prompt)
X = 10:20
sigma_y = 0.22 * X .* (1+0.0001 * X) .^ (-1/2);
sigma_z = 0.20 * X;
Ground_Level_Conc = (Qm ./ (3.142 * sigma_y .* sigma_z * u)) .* exp((-1/2) * (Hr ./ sigma_z).^2);
plot(X, Ground_Level_Conc,'b.-', 'LineWidth', 2, 'MarkerSize', 35);
grid on;
xlabel('Downwind Distance (m)', 'FontSize', fontSize);
ylabel('Ground Level Concentration (mg/m3)', 'FontSize', fontSize)
title('Dispersion Graph', 'FontSize', fontSize);
T = table(X(:), Ground_Level_Conc(:), 'VariableNames', {'X', 'Ground_Level_Conc'})
You get:
T =
11×2 table
X Ground_Level_Conc
__ _________________
10 30434.2298807828
11 27433.7609215154
12 24625.9930266501
13 22090.138086257
14 19840.4186733388
15 17861.8152379357
16 16127.8535265598
17 14609.1873783254
18 13277.5293156971
19 12107.2612860361
20 11075.9140796537

Tags

Community Treasure Hunt

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

Start Hunting!