how can I define an excel woorksheet in Matlab that consider the location of cells with equal numeric value and change them into specific values that I want.

1 view (last 30 days)
how can I define an excel worksheet in Matlab that consider the location of cells with equal numeric values and change them into specific values that I want. in other word I want : Region 1 = locations of all cells with numerical values of A Region 2 = locations of all cells with numeric value of B And so on. and then change each region to specific values that I want. and repeat it and each time changing region s first value to specific values, as many times that I want . each region has so many cells therefor I cant define them cell by cells in matlab.

Accepted Answer

dpb
dpb on 16 Mar 2014
It's so trivial in Matlab; just import the array; make the changes and rewrite (assuming you must use Excel at all; why can't you just use Matlab?)
data=xlsread('yourfile.xls');
data(data==A)=newA;
data(data==B)=newB;
xlswrite('yourfile.xls',data)
You may have the problem depending on the values addressed in the FAQ--
  13 Comments
baran
baran on 18 Mar 2014
thanks so much , if "A" has value , for example all cells with value 2 , that when excel link to matlab "2" go to functions and change to another value and 2 in my program is a number and it is not symbol, then is it still true ? and what do you mean " if firstflag ..." can you explain more ? thanks.
dpb
dpb on 18 Mar 2014
I don't know about how you're doing the "Excel link to Matlab" specifically, but certainly you'll have to fix any issue of whether the value passed is the character representation (a string/character variable) or the value itself. That should be relatively simple to deal with.
The "firstflg" is a variable you set to know whether the index array needs to be updated or whether to use the previously computed one. It's a local variable to Matlab controlled by whoever is in charge of the overall process which you've yet to describe how this whole thing is structured.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!