Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

I tried debugging the code it works until it reaches line 31 (temp=pad...) i dont know what i am doing wrong but can u help me with this error it is indicated after the code

1 vue (au cours des 30 derniers jours)
Talal
Talal le 1 Nov 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
close all clear all
load C:\Users\Traddadi\Desktop\biomed_img\project_2\rfdata\cystdata ri theta
fc=5e6; % center freq in Hz fs=5e7; % sampling freq in Hz r0=0.07; % focal depth in m dt=1/fs; xn=ri/1000; c=1540; % acoustic wave velocity in the medium in m/s t=2*r0/c; % time in
d = dir('*.mat'); % looks for .mat-Files for i = 1: 127 load(['rfline' num2str(i) '.mat']) for j= 1:128 tau(j)=(((xn(j).^2*cos(theta(i)).^2)/2*c*r0)-(xn(j).*sin(theta(i))./c)); end end
tau % notes delay =abs(tau)*fs; max_delay=max(delay); pad=zeros(8192,length(xn));
for i = 1: 128 rflines=sum(pr,2); temp=pad(rflines,delay(1,i),'post'); temp=pad(rflines,max_delay(1,i),'pre'); rfdata(:,i)=temp; end
figure, imagesc(abs(hilbert(rfdata))) colormap(gray)
when I run the code i have the following error:
??? Subscript indices must either be real positive integers or logicals.
Error in ==> test_bio_code_pj2 at 31 temp=pad(rflines,delay(1,i),'post');
  4 commentaires
Laurent
Laurent le 1 Nov 2013
Thanks Image Analyst, only now I realize that Talal was actually posting the code of test_bio_code_pj2. I was confused because I didn't see 31 lines.

Réponses (1)

Iain
Iain le 1 Nov 2013
Put a breakpoint in your code at line 31, and look in the memory of the function for a variable called pad. I suspect that you load in a variable with that name, so that when you attempt:
temp = pad(rflines,delay(1,i),'post');
That matlab identifies "pad" as a variable, then attempts to access it using the index " 'post' ", which is garbage.
padarray might be a better option than pad.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by