Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

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

2 visualizzazioni (ultimi 30 giorni)
BHARAT SINGH RAWAT il 30 Dic 2019
Chiuso: MATLAB Answer Bot il 20 Ago 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!!)-------------%
[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, ...%

### Risposte (1)

James Browne il 8 Gen 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 CommentiMostra NessunoNascondi Nessuno
BHARAT SINGH RAWAT il 8 Gen 2020
Do you know anyway to correct that?
James Browne il 9 Gen 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...

Questa domanda è chiusa.

### Community Treasure Hunt

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

Start Hunting!

Translated by