Error using quad (line 70)

조회 수: 11 (최근 30일)
Maedeh Mashhadbani
Maedeh Mashhadbani 2020년 11월 16일
댓글: Maedeh Mashhadbani 2020년 11월 16일
i write this code for value V=0 i see this error
clc; clear all;
n=10; t=-2.66; E0=0; eta=15*10^(-2); KbT=0.0258; Ef=0;
alphag=1; alphad=0.5; Vg=0; U=0; j=0; phi=0; a0=1.42; a=1; b=1;
sigmaR=zeros(6,6);
sigmaL=zeros(6,6);
%E=-10:2*10/n:10;
kx=-pi/(3*a0); %:pi*2/(3*a0*100):pi/(3*a0)
%a=exp(-i*kx*a0/2);
%b=exp(i*kx*a0);
V=0;
syms E;
UL=0;
%UL=-(alphag*Vg)-(alphad*V(l));
mu1=Ef;
mu2=Ef-V;
Hc=[E+i*eta-E0 -b*t 0 -a*t 0 0;-b'*t E+i*eta-E0 -a'*t 0 0 0; 0 -a*t E+i*eta-E0 0 0 -a*t; -a'*t 0 0 E+i*eta-E0 -a'*t 0; 0 0 0 -a*t E+i*eta-E0 -b*t; 0 0 -a'*t 0 -b'*t E+i*eta-E0];
sigmaR(3,3)=(-t)*exp(i*kx*a0);
sigmaL(4,4)=(-t)*exp(i*kx*a0);
gamaR=i*(sigmaR-sigmaR');
gamaL=i*(sigmaL-sigmaL');
Gc=inv(Hc-sigmaR-sigmaL);
T=trace(gamaR*Gc*gamaL*Gc');
f1=1./(1+exp((E+UL-mu1)));
f2=1./(1+exp((E+UL-mu2)));
I=T.*(f1-f2);
current=quad(vectorize(I),-10,10)
Error using quad (line 70)
The integrand function must return an output vector of the same length as the input vector.
Error in test (line 26)
current=quad(vectorize(I),-10,10)
  댓글 수: 2
John D'Errico
John D'Errico 2020년 11월 16일
편집: John D'Errico 2020년 11월 16일
What is I?
I
I =
0
I is a scalar. It is not even a function. The last time I checked, the integral of 0 over pretty much any interval you want is still ero. As for why you are using the old quad code, I have no idea, but even quad would be able to integrate it, if you actually provided a function.
A numerical integration tool must be passed a FUNCTION. Not a scalar, ot even a vector. If that is what you wanted to do, then use trapz or cumtrapz.
Maedeh Mashhadbani
Maedeh Mashhadbani 2020년 11월 16일
i used int but it didnt work i try quad and it workes i dont know why int didnt work

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by