warning: implicit conversion from matrix to string

Vic Norton vic at norton.name
Tue Sep 2 19:31:24 CDT 2008


How do I get rid of implicit conversion warnings when printing an  
array of strings of the same length? For example the script

	% test2.m

	global SEC_PER_HOUR = 3600;
	SEC_PER_DAY = 24 * SEC_PER_HOUR;
	SEC_PER_WEEK = 7 * SEC_PER_DAY;
	
	function  date = time2dateEST( time )
	## The date returned is the "%Y-%m-%d"-formatted EST date
	## corresponding to time.
		global SEC_PER_HOUR;
		time -= 5 * SEC_PER_HOUR;
		date = strftime("%Y-%m-%d", gmtime( time ) );
	endfunction
	
	dates = zeros(5, 10);
	time = 1082667600;
	for i = 1 : 5
	   dates(i, :) = time2dateEST(time);
	   time += SEC_PER_WEEK;
	endfor
	
	for i = 1 : 5
	   printf("%s\n", dates(i, :));
	endfor

produces

	octave-3.0.2> test2
	warning: implicit conversion from matrix to string
	2004-04-22
	warning: implicit conversion from matrix to string
	2004-04-29
	warning: implicit conversion from matrix to string
	2004-05-06
	warning: implicit conversion from matrix to string
	2004-05-13
	warning: implicit conversion from matrix to string
	2004-05-20

on my system.

Obviously the dates have been "converted" correctly. What is the  
problem here?

Regards,

Vic


More information about the Help-octave mailing list