How to create code that runs on all columns?
이전 댓글 표시
I am trying to run this code on all columns in my dataset.
n = 167;
b = arrayfun(@(i) mean(A.Echo1_500kHz.volumeBackscatter_dB(i:i+n-1)),1:n:length(A.Echo1_500kHz.volumeBackscatter_dB)-n+1)';
I need the code to also be able to be used on data sets of varying column lengths.
I have tried and failed at trying to create a loop. Im sure it is simple however I am really strugling!
The below code is what I am currently running for my pcolor plot. I would like to average 167 0.006m depth bins into 1m bins. The aim is to show the differnece in resolution between two oceanographic instruments. One that samples at 0.006m and does no processing and one that also samples at the same rate but averages into 1m bins instead of recording the raw data.
load('2CawsandDevil0.006-11.23.28-12.20.29.mat')
d=datestr(A.Echo1_500kHz.timestamp)
t=datetime(d)
t=t.'
dd1=downsample(A.Echo1_500kHz.volumeBackscatter_dB,167)
de1=downsample(A.Echo1_500kHz.binDepth_m,167)
subplot (4,1,1)
A.Echo1_500kHz.timestamp
f1=pcolor(t,A.Echo1_500kHz.binDepth_m,A.Echo1_500kHz.volumeBackscatter_dB)
%shading interp
set(f1, 'EdgeColor', 'none');
colormap jet
caxis([100,140])
colorbar
set(gca,'ydir','reverse')
ylim([0,35])
ssection=datetime(2020,11,10,12,12,00)
esection=datetime(2020,11,10,12,20,00)
xlim([ssection,esection])
grid on
ylabel ('Depth (m)','fontsize',14)
xlabel('','fontsize',14)
title('2CawsandDevil data 0.006m')
set (gca,'fontsize',14)
x=datetime(2020,11,10,11,36,08)
x1=datetime(2020,11,10,12,17,08)
댓글 수: 4
dpb
2020년 12월 31일
Tell us what are you trying to compute and what are the inputs instead of trying to decipher nonworking code...
You probably don't need a loop at all.
Thomas Blacklock
2020년 12월 31일
Image Analyst
2020년 12월 31일
Thomas, can you upload your data?
Thomas Blacklock
2020년 12월 31일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Red에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!