Error in calculate mean and standar deviation

조회 수: 1 (최근 30일)
Retno Purwaningsih
Retno Purwaningsih 2021년 11월 16일
댓글: Retno Purwaningsih 2021년 11월 16일
Helloo, i had a problem with the script. So i used this script to calculate mean and standar deviation of each row from column 4 to end. I used this script and work in first file but in the next file i face some error like this
Warning: Variable names were modified to make them valid MATLAB identifiers.
The original names are saved in the VariableDescriptions property.
Error using script_msl_v2 (line 17)
Variable index exceeds table dimensions.
With this script and the file
clear;
clc;
format longG;
f = dir('E:\Sentinel-Cryosat\sentinel\full_Data_Sentinel_c2p0006.txt');
A=1:length(f);
D = f(A).name;
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
ff= D(:,20:26)
data=readtable(D,'HeaderLines',0);
rata2=mean(data{:,4:end},2,'omitnan');
standar_deviation=std(data{:,4:end},[],2,'omitnan');
%ud=getTrend(data{:,4:end},2,'omitnan');
%ref=data{:,1};
lat=data{:,2};
lon=data{:,3};
msl=[lat lon rata2 standar_deviation]
%file_name_msl=['msl_' ff '.txt']
%dlmwrite(file_name_msl, rata2, 'delimiter', '\t');
file_name_data=['data_rata2_std_' ff '.txt']
dlmwrite(file_name_data, msl, 'delimiter', '\t','precision',10);
Thanks to anyone who can help me

답변 (1개)

Matt J
Matt J 2021년 11월 16일
Why not just
data=readtable('E:\Sentinel-Cryosat\sentinel\full_Data_Sentinel_c2p0006.txt','HeaderLines',0);
  댓글 수: 3
Matt J
Matt J 2021년 11월 16일
Remove the previous lines of code,
data=readtable('E:\Sentinel-Cryosat\sentinel\full_Data_Sentinel_c2p0006.txt','HeaderLines',0);
rata2=mean(data{:,4:end},2,'omitnan');
standar_deviation=std(data{:,4:end},[],2,'omitnan');
%ud=getTrend(data{:,4:end},2,'omitnan');
%ref=data{:,1};
lat=data{:,2};
lon=data{:,3};
msl=[lat lon rata2 standar_deviation]
%file_name_msl=['msl_' ff '.txt']
%dlmwrite(file_name_msl, rata2, 'delimiter', '\t');
file_name_data=['data_rata2_std_' ff '.txt']
dlmwrite(file_name_data, msl, 'delimiter', '\t','precision',10);
Retno Purwaningsih
Retno Purwaningsih 2021년 11월 16일
still got error like this @Matt J
Warning: Variable names were modified to make them valid MATLAB
identifiers. The original names are saved in the VariableDescriptions
property.
Error using script_msl_v2 (line 7)
Variable index exceeds table dimensions.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by