Not able to write the image by reading xcel files generated , getting error of data type as shown in picture attached. Anybody please help.

Answers (5)

You cannot do that. The result of imagesc is an OOP object, and OOP objects cannot be written to excel files.
Perhaps for your purposes it would be good enough to change
z = imagesc(n);
to
z = rescale(n);
This is not very clear, it would be better to copy the code instead of figures and provide a sample file so that the case can be reproduced. However, there is a clear error in the following:
z=imagesc(n);
imwrite(z...)
When you do z=imagesc(n) you are using z as a handle to the image that will be generated with imagesc, for instance:
n=randn(65);
z=imagesc(n);
get(z)
AlphaData: 1 AlphaDataMapping: 'none' BeingDeleted: off BusyAction: 'queue' ButtonDownFcn: '' CData: [65×65 double] CDataMapping: 'scaled' Children: [0×0 GraphicsPlaceholder] Clipping: on ContextMenu: [0×0 GraphicsPlaceholder] CreateFcn: '' DeleteFcn: '' HandleVisibility: 'on' HitTest: on Interpolation: 'nearest' Interruptible: on Parent: [1×1 Axes] PickableParts: 'visible' Selected: off SelectionHighlight: on Tag: '' Type: 'image' UserData: [] Visible: on XData: [1 65] YData: [1 65]
Clearly that is not what you want to save as an excel file.

3 Comments

for i=10
im=imread(['C:\Users\Nikhil\Desktop\Manu Gowda\ground test\DIP\photoes\green\green' num2str(i) '.jpg']);
[x,y]=size(im)
m=x/2;
line=im(m,1:y);h
plot(line);
w1=137;
w2=142;
%w1 = input('width of fuel W1=');% entering the width of fuel by plot
%w2 = input('width of fuel W2=');% entering the width of fuel by plot
for i=1:6
im=imread(['C:\Users\Nikhil\Desktop\Manu Gowda\ground test\DIP\photoes\green\green' num2str(i) '.jpg']);
t=im(1:x,w1:w2);
b=t';
s=mean(b);
%u=arrayfun(@(x) sprintf('%10.0f',x),s,'un',0);
filename=['avg', num2str(i), '.xlsx'];
xlswrite(filename,s);
end
for k=1
basefilename = 'avg';
extension = num2str(k);
filename = strcat(basefilename, extension, '.xlsx');
n = xlsread(filename);
z=imagesc(n);
imwrite(z,['averaged' int2str(k), '.jpg']);
end
error i am getting
Error using imwrite (line 420)
Expected DATA to be one of these types:
numeric, logical
Instead its type was matlab.graphics.primitive.Image.
Error in updated (line 32)
imwrite(z,['averaged' int2str(k), '.jpg']);
Back to the same point z is a handle to the image, but if you want to output that as a file (say a png) you do not use imwrite like that, try this
n=randn(65);
z=imagesc(n);
imwrite(n,'testfile.png')

Sign in to comment.

Products

Release

R2015a

Asked:

on 4 Jan 2022

Answered:

on 25 Jan 2022

Community Treasure Hunt

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

Start Hunting!