Grretings to all!
In the Regression Kriging, i want to create a map for Standard Deviation of the Ordinary and the Regression Kriging.
The pH.sd (from the OK, Ordinary Kriging) are in a matrix: double [250292]
The pH.regkrig.sd (from the RK, Regression Kriging) are in a matrix: double [11681312]
When i try to create the ratio: pH.regkrig.sd/pH.sd it says:
"Error in (mydata.regkrig$pH.regkrig.sd)/(mydata.krig$pH.sd) :
non-conformable arrays"
Any idea with what code i can fix it so as to plot the map?
Thanks in advance
I tried to make them same length but it failed
Related
I write following code in MATLAB to apply int2int lifting wavelet transform to the lena.jpg image.
I=imread('lena.jpg');
im=double(I);
lshaarInt = liftwave('haar','int2int');
els = {'p',[-0.125 0.125],0};
lsnewInt = addlift(lshaarInt,els);
[LL1,HL1,LH1,HH1] = lwt2(im,lsnewInt)
LL1=uint8(LL1);LH1=uint8(LH1);HL1=uint8(HL1);HH1=uint8(HH1);
figure()
subplot(2,2,1);imshow(LL1);
subplot(2,2,2);imshow(LH1);
subplot(2,2,3);imshow(HL1);
subplot(2,2,4);imshow(HH1);
Now I apply inverse LWT using following code without applying any other operations on sub-bands:
LL1=double(LL1);LH1=double(LH1);HL1=double(HL1);HH1=double(HH1);
wmd1= (ilwt2(LL1,HL1,LH1,HH1,lsnewInt));
wmd=uint8(wmd1);
I compare two images 'I' and 'wmd' using Normalized Co-relation Coefficient (NCC)
In output, in place of 1 as a answer I got 0.9994.
When I compare the intensity values of two images then the values are not same.
LWT is the lossless data technique but i found that the data loss.
Please suggest me where I am wrong.
I found the solution
The problem is with following code:
LL1=uint8(LL1);LH1=uint8(LH1);HL1=uint8(HL1);HH1=uint8(HH1);
No need to convert all the above values from double to int.
I got NCC value as 1 when I gave comment to above statement.
Thank you for response.
I have this matlab code for creating averages of several images:
cd('C:\images')
all_images=dir('*.jpg');
[sj,xx]=size(all_images);
j=1;
file_name=char(all_images(j).name);
tmp=imread(file_name);
[m,n]=size(tmp);
template=zeros(m,n);
for i=1:length(all_images)
file_name=char(all_images(i).name);
tmp=double(imread(file_name));
template=template+tmp;
end
template=template/length(all_images);
imagesc(template)
imwrite(uint8(template),'template.jpg','jpg')
The case is that I obtained the following error:
Error
using + Matrix dimensions must agree.
Error
in averagetemplate (line 15) template=template+tmp;
Any idea? I have to say that I am newbie in matlab coding.
Thanks
Just change [m,n]=size(tmp) in line 6 to [m,n,~]=size(tmp)and your problem will be solved.
In the below code :
[m,n]=size(tmp)
Matlab is computing n*3 as the column of matrix so you will get the dimension error in next few line.
You are overwriting your temp variable with what appears to be a single value here:
tmp=double(imread(file_name));
and it may be different dimensions M x N regardless. Matlab is saying to add matricies they have to have same number of rows and cols.
I am trying to model a graph as shown in the attached image. The equation for which I am modelling is also shown in the image.
My codings are,
sigmafu=1660;
phi=0.0:0.01:90;
e=2.7183; %I searched on internet to find e value of Euler number and I
%found this.
%Dont know whether MATLAB bydefault has value of e, like MATLAB has value
%pi.
pw= (-0.3)*phi*(180/180);
F=sigmafu*(0)* 2.7183^(pw);
plot (phi,F)
I am getting the following error by using the above codings:
Error using ^. Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead.
Error in myeqsetlin (line 126): F=sigmafu*(0)* 2.7183^(pw);
Can anyone help me correct the code? Also, does MATLAB have the default value of e (Euler's number), if so how can I use it?
You can get the value for e with exp(1). meaning e^1.
sigmafu = 1660;
phi = 0.0:0.01:90;
pw = -0.3*phi*pi/180;
F = sigmafu*exp(pw);
plot(phi,F)
I am trying to compute the following expected value for Z being lognormally distributed
E[Z^eta w(F_Z (Z))^-eta]
where eta is a real number, F_Z the distribution function of Z and w:[0,1]->[0,1] an increasing function.
First of all, I am pretty new to Matlab so I don't know which way of integrating is the better one, numerically or symbolically. I tried symbolically.
My idea was to subsequently define functions:
syms x;
g_1(x) = x^eta;
g_2(x) = logncdf(x);
g_2(x) = w(x)^-eta;
g_4(x) = g_1(x) * g_3(g_2(x));
And then
exp = int(g_4(x),x,0,inf)
Unfortunately this doesn't work and MATLAB just posts the whole expression of g_4...
Is it better to use the numerical integration quadqk? What am I doing wrong here? I already read something about MATLAB not being the best program for integration but I have to use it so switching to a different program does not help.
Thanks a lot!
I am trying to program in Matlab a conditional expectation of the form:
E[x|A<=x<=B] where X~N(u,s^2) (sorry, apparently the math editing here isn't what I am used to)
In Matlab, I have written up the following code:
Y=u+s*(normpdf(A,u,s)-normpdf(B,u,s))/(normcdf(B,u,s)-normcdf(A,u,s))
the problem is that it breaks down at higher values of A and B. For example, let u=0, s=1, A=10 and B=11. Simple logic says the answer should be between 10 and 11, but Matlab gives me back Inf because the denominator essentially becomes 0 while the numerator is 10^-23.
Any suggestions to make the formula give real numbers for all inputs?
One way is to do the numerical integration yourself:
x = linspace(A,B,1000);
trapz(x,x.*normpdf(x,u,s)) / trapz(x,normpdf(x,u,s))
With your example values, this gives 10.0981, and it is pretty fast