Error: Undefined function 'minus' for input arguments of type 'cell'

22 Ansichten (letzte 30 Tage)
Uday padidela
Uday padidela am 16 Jun. 2014
Bearbeitet: Sean de Wolski am 16 Jun. 2014
Hii all, I am trying to read a large text file with about 1001 rows and 5 columns. And my first row is with strings (#r g00 g01 g10 g11) and the numerics start from 2nd row. And I want to change the numerical values of four columns(g00 g01 g10 g11) in my code to (g00-1 g01-1 g10-1 g11-1) and use it as an input for calculating my equation. This is my text file #r g00 g01 g10 g11 0.025 0 0 0 0 0.075 0 0 0 0 0.125 0 0 0 0 0.175 0 0 0 0 0.225 0 0 0 0 0.275 0 0 0 0 0.325 0 0 0 0 0.375 0 0 0 0 0.425 0 0 0 0 0.475 0 0 0 0 0.525 0 0 0 0 0.575 0 0 0 0 0.625 0 0 0 0 0.675 0 0 0 0 0.725 0 0 0 0 0.775 0 0 0 0.005235893 0.825 0 0 0 0.06846978 0.875 0 0 0 0.310699895 0.925 0 0 0 0.63992878 0.975 0 0 0 0.843685179 1.025 0 0 0 0.966970842 1.075 0 0 0 0.97488415 1.125 0 0 0 1.044026487 1.175 0 0 0 1.009890799
I used this code
fileID = fopen('size_5.txt', 'r');
formatSpec = '%f %f %f %f %f';
N = 5;
C_text = textscan(fileID,formatSpec,N,'delimiter','\t');
C_data0 = textscan(fileID,'%f %f %f %f %f')
frewind(fileID);
C_text = textscan(fileID,'%f %f %f %f %f',N,'delimiter','\t');
fclose(fileID);
h11= (C_data0(:,2))-1; h12= (C_data0(:,3))-1; h21= (C_data0(:,4))-1; h22=(C_data0(:,5))-1;
Can any one help me?
Thank You!!!

Antworten (1)

Sean de Wolski
Sean de Wolski am 16 Jun. 2014
Bearbeitet: Sean de Wolski am 16 Jun. 2014
You cannot subtract cell arrays. Perhaps you meant to subtract the contents of the cell array?
% Two cells
C = {1}
C2 = {2}
% subtract their contents using {}
C{1}-C2{1}

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by