Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
BHARAT SINGH RAWAT
BHARAT SINGH RAWAT am 30 Dez. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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, ...%

Antworten (1)

James Browne
James Browne am 8 Jan. 2020
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 Kommentare
James Browne
James Browne am 9 Jan. 2020
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...

Diese Frage ist geschlossen.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by