Info

This question is closed. Reopen it to edit or answer.

How can I edit this code ?

1 view (last 30 days)
ND
ND on 30 Nov 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
Please I have this code
% code
ex = dlmread( 'BB.txt' ) ; %output data
S11 = dlmread( 'AA.txt' ) ; % input data
buffer = [S11,ex] ;
[~, ca] = unique( buffer, 'rows' ) ;
buffer = buffer(sort(ca),:) ;
Mshuffled = buffer(randperm(size(buffer,1)),:);
x1Range= 'B';
xlswrite( 'first.xlsx', [{'S11'}; num2cell( Mshuffled(:,1) )], 'X',x1Range) ;
xlswrite( 'first.xlsx', [{'E11'}; num2cell( Mshuffled(:,2) )], 'Y' ) ;
I need to multiply the data in (ex.txt) by 10^4 . So all rows in E11 column will be multiplied by this factor. Is that possible?
Many thanks

Answers (1)

Image Analyst
Image Analyst on 30 Nov 2015
Yes, but first you need to call dlmread('ex.txt') which you have not done yet. You've only read in AA.txt and BB.txt.
exData = dlmread( 'ex.txt'); % Input data
Next, I don't know what the "E11" column is. Columns have only letters, not letters and numbers. Do you mean the column that cell E11 is in, which, of course, is column "E" (column 5)? If so then:
% Multiply column 5 by 10^4
exData(:, 5) = exData(:, 5) * 10000;

Community Treasure Hunt

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

Start Hunting!