Hi, I'm working on a problem for a homework assignment to print a cell array with a substructure. My code (I know its a bit lengthy, is as follows):
From3=struct('x',1,'y',2);To3=struct('x',7,'y',5);From2=struct('x',3,'y',5);To2=struct('x',4,'y',7);From1=struct('x',5,'y',6);To1=struct('x',2,'y',10);lineseg(3)=struct('Line',3,'From',From3,'To',To3);lineseg(1)=struct('Line',1,'From',From2,'To',To2);lineseg(2)=struct('Line',2,'From',From1,'To',To1);fprintf('%-20s %-20s %-20s\n','Line','From','To')for k=1:length(lineseg) Line=lineseg(k).Line; From=lineseg(k).From; To=lineseg(k).To; fprintf('%.1f %.1f %.1f\n', Line,From,To); k=k+1 end
However, when I try to publish this, I get the error message: Error using fprintf Function is not defined for 'struct' inputs. I am 99% sure that it is due to the fact that there is a substructure, so how would i be able to publish this successfully?
Best Answer