Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

I am getting error in the following code can anyone help and suggest?

조회 수: 1 (최근 30일)
BHARAT SINGH RAWAT
BHARAT SINGH RAWAT 2019년 12월 30일
마감: MATLAB Answer Bot 2021년 8월 20일
clc;
clear all;
close all;
%-------Date:20122019--------Doppler Shift Spectroscopy Experiment Data---%
%Grating :1200lines/mm Acquistion time:10s slit width:50M=mircon%
%Pressure 2E-4 Torr%
Ar=3.14; %Area in cm2 of one FC
calF = 1000/(Ar*100); % calbration for mA/cm2
%------------HV:600V--------------No suppressor bias to FC (Forgot!!)-------------%
a1 =csvread('WAVE0001.CSV',11,0);%Line 696nm %
a2 =csvread('WAVE0002.CSV',11,0);%Line 750nm %
a3 =csvread('WAVE0003.CSV',11,0);%Line 763nm %
a4 =csvread('WAVE0004.CSV',11,0);%Line 772nm %
a5 =csvread('WAVE0005.CSV',11,0);%Line 811nm %
[Y, R, K, B, Z, D] = deal(zeros(11,1)); %pre allocation of arrays
A1=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y1=mean(a1(71:81,2:12))*1000*calF;
Y2=mean(a2(71:81,2:12))*1000*calF;
Y3=mean(a3(71:81,2:12))*1000*calF;
Y4=mean(a4(71:81,2:12))*1000*calF;
Y5=mean(a5(71:81,2:12))*1000*calF;
figure(1)
plot(A1,Y1,'or',A1,Y2,'ob',A1,Y3,'oc',A1,Y4,'om',A1,Y5,'ok','LineWidth',2,'MarkerSize',10);
hold on
grid on
for i=1:length(R)
R(i) = fit(A1',Y(i)','gauss1')
for j = 1:length(K)
K(j)=coeffvalues(R(i))
K3(j) = K(3)
K1(j) = K(1)
for q = 1:length(B)
B(q) = sqrt(2)*K(j) ;
for s = 1:length(Z)
Z(s)=9.4*K1(j)*K3(j).^2*10E-3;
for t = 1:length(D)
D(t)=(180/3.14)*atan((B(q)-55)/(628));
end
end
end
end
end
%Error:Error using fit>iFit (line 135)
X and Y must have the same number of rows.
Error in fit (line 108)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...%

답변 (1개)

James Browne
James Browne 2020년 1월 8일
I think your problem is here:
R(i) = fit(A1',Y(i)','gauss1')
you are inputting the vector "A1" but only one value from the vector "Y". Fit creates a mathematical relationship between the elements of the input vectors, so "Y(i)" is the problem, since that refers to one index in Y and not the whole vector.
  댓글 수: 2
BHARAT SINGH RAWAT
BHARAT SINGH RAWAT 2020년 1월 8일
Do you know anyway to correct that?
James Browne
James Browne 2020년 1월 9일
Without knowing exactly what your code is trying to do and without being able to test it, I am not sure that I could figure out how to correct it...

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by