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

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

The error seems to happen in your function 'test_bio_code_pj2'. Since this is not a standard Matlab function, you should provide it. Otherwise there is no way that someone can help you to solve the problem.
Probably
rflines
or
delay(1,i)
is not well defined. Did you set 'i' correctly in the test_bio_code_pj2?
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.

답변 (1개)

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.

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

질문:

2013년 11월 1일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by