Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Magnatic field in surface coil for overlapping conductor
1 回表示 (過去 30 日間)
古いコメントを表示
Dear All
Please can you help urgently
I do not know where is the error.
clear all close all condition = 1;
while (condition)
L = input('Please enter the grid length and size [l s]: ');
N = L(2); l = L(1); dl = l/N;
miu0 = 4*pi*1e-7/1000;
I1 = 1; I2 = -1; width = 1/dl;
%%Grid Calculations.
offset = input('Please enter the position for wire 1 in cm: ');
offset = ceil(offset/dl);
overlap = input('Please enter the %age Overlap between two coils: ');
overlap = overlap*N/100;
n_slices = input('Please enter the number of slices: ');
loc = input('Please enter the location of the first slice in mm: ');
loc = ceil(loc/(10*dl));
x= -N/2:N/2;
y=-N/2:N/2;
% Setting Location of the wire points.
p11 = offset;
p12 = p11+width;
mid1 = p11+width/2;
mid2 = mid1 + ceil((1-overlap/100)*width);
p21 = mid2-width/2;
p22 = p21+width;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ((p11<0) || (p12<0) || (p21<0) || (p22<0) || (p11>N+1) || (p12>N+1) || (p21>N+1) || (p22>N+1))
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('Wires do not fit on the grid, Please enter new dimensions')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
else
condition = 0;
for i = 1: length(x)
for j = 1: length(y)
% Calculating distance vectors
r1(i,j) = sqrt((x(p11) - x(i))^2 + (y(j))^2);
r2(i,j) = sqrt((x(p12) - x(i))^2 + (y(j))^2);
r3(i,j) = sqrt((x(p21) - x(i))^2 + (y(j))^2);
r4(i,j) = sqrt((x(p22) - x(i))^2 + (y(j))^2);
end
end
%Calculating magentic fields
B1 = (miu0*I1)./(2*pi*r1);
B2 = (miu0*I2)./(2*pi*r2);
B3 = (miu0*I2)./(2*pi*r3);
B4 = (miu0*I1)./(2*pi*r4);
B = B1+B2+B3+B4;
% Selecting reference axis
Ref_axis = B(N/2+1:N,p21+ceil((p12-p21)/2));
test_lines = B(128:256,128:256);
test_avg_H = sum(test_lines,2)/128;
test_avg_V = sum(test_lines,1)/128;
%%%%%Taking slices of the Signal Decay %%%
Brain = test_avg_V(loc:ceil(loc+5.5/(10*dl)));
l_Brain = length(Brain);
new_dim = ceil(l_Brain/n_slices);
new_Brain = padarray(Brain,[0 new_dim*n_slices-l_Brain],0,'post');
l_Brain = length(new_Brain);
pulses = zeros(l_Brain,n_slices);
sig = reshape(new_Brain, [new_dim n_slices]);
slices = (sig(ceil(length(sig)/2),:)); % Taking mid-point of each rectangular pulse.
slices = (slices);
for i = 1:n_slices
pulses((i-1)*l_Brain/(n_slices)+1:l_Brain/(n_slices)*i,i) = slices(i);
fft_pulses(:,i)=fftshift(fft(pulses(:,i))); % moving the zero-frequency component to the center of the array
Nf=length(fft_pulses(:,i)); %to take the frquecny axis of the hoarmonics.
n=-(Nf-1)/2:(Nf-1)/2; %divide the frequency compone
f(:,i)=sqrt(fft_pulses(:,i).*conj(fft_pulses(:,i))); % to take the amplitude of each hoarmony.
figure;
plot(f(:,i));
title('Fourier Transform of the pulses');
xlabel('frequency ');
ylabel('Amplitude');
end
pulses = padarray(pulses,loc,0,'pre');
pulses = padarray(pulses,100,0,'post');
%Plotting figures
figure;
bar(pulses,5,'hist');
hold on
plot(test_avg_V);
% figure % plot(pulses) % hold on % plot(flipud(test_avg_V)); figure; plot(f); figure; plot(test_lines') title('test lines') figure; plot(test_avg_V); title('Magnetic Field Decay Ratio'); xlabel('Distance on y-axis'); ylabel('B1');
figure
surf(x,y,B);
view(0,90);
colorbar;
xlabel('x');
ylabel('y');
title('B1 Profile');
end
end
Regards
Dhafer
1 件のコメント
回答 (1 件)
Youssef Khmou
2013 年 3 月 6 日
hi,
delete this portion :
L = input('Please enter the grid length and size [l s]: ');
N = L(2); l = L(1);
And replace it with :
N = input('Please enter the grid length :');
l=input('Enter the grid size');
3 件のコメント
Youssef Khmou
2013 年 3 月 6 日
編集済み: Youssef Khmou
2013 年 3 月 6 日
hi Dhafer , the new error is not technical , but its about the conception of the code or the entered values, i think the error is
1) Matrix dimensions must agree or
2) Index exceeds
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!