When running this I get the error message:
Error using *
Inner matrix dimensions must agree.
Error in opticaldepth (line 14)
tau(iz,il) = tau(iz,il) + s_abs(il,ij).*sum((Nj(iz:end)*z),ij);
Error in task2 (line 61)
tau = opticaldepth( z,lambda,Nj,s_abs );
It does not work using .* instead.
I get that dimensions doesnt agree, but i thought it did. Can anyone see a solution?
function [ tau ] = opticaldepth( z,lambda,Nj,s_abs )
load('msis20120223_12.dat.txt') % 621x3 matrix
z = msis20120223_12_dat(:,1);
nN2 = msis20120223_12_dat(:,2);
nO = msis20120223_12_dat(:,3);
nO2 = msis20120223_12_dat(:,4);
Nj = [ nN2(:,1) nO(:,1) nO2(:,1) ];
load('PhotAbs.dat.txt')
lambda = PhotAbs_dat(:,1); % 20x3 matrix
sigN2 = PhotAbs_dat(:,2);
sigO = PhotAbs_dat(:,3);
sigO2 = PhotAbs_dat(:,4);
s_abs = [ sigN2(:,1) sigO(:,1) sigO2(:,1) ];
nz = length(z); %621
nl = length(lambda); %20
dz = gradient(z);
tau = zeros(nz,nl);
for il = 1:nl,
for iz = 1:nz,
for ij = 1:3,
tau(iz,il) = tau(iz,il) + s_abs(il,ij).*sum((Nj(iz:end)*z),ij);
end
end
end
tau = opticaldepth( z,lambda,Nj,s_abs );

Réponses (1)

James Tursa
James Tursa le 18 Mai 2015
What are you trying to do here?
Nj(iz:end)*z
Nj is a matrix with 3 columns and you are using linear indexing into it, which is probably not what you intended.

1 commentaire

kdyrland
kdyrland le 18 Mai 2015
I'm trying to implement an integral, Nj*dz over z_0 to z_max.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by