Error in calculate mean and standar deviation

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

Answers (1)

Why not just
data=readtable('E:\Sentinel-Cryosat\sentinel\full_Data_Sentinel_c2p0006.txt','HeaderLines',0);

3 Comments

i modify the script just like you did, but still facing the same error
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);
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.

Sign in to comment.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Release

R2017a

Asked:

on 16 Nov 2021

Community Treasure Hunt

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

Start Hunting!