Throw an error message with the dimensions of a matrix
    5 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Christian Berwanger
 am 22 Dez. 2020
  
    
    
    
    
    Beantwortet: Star Strider
      
      
 am 22 Dez. 2020
            Hello,
I want to throw an error message with the size of my matrices:
The minimal working example would be this one:
M = magic(3);
N = magic(4);
error(['size(M) = ' size(M) newline 'size(N) = ' size(N)])
The problem is that the output of size() is not a string so my error message looks like:
size(M) = 
size(N) = 
Is it possible to somehow print the dimensions of my matrix in an error message? My first intuition would be to save the return of size(M). but I couldn't find any solution for this.
Kind Regards,
Christian
0 Kommentare
Akzeptierte Antwort
  Star Strider
      
      
 am 22 Dez. 2020
        M = magic(3);
N = magic(4);
error(['size(M) = ' num2str(size(M)) newline 'size(N) = ' num2str(size(N))])
produces: 
Error using ... (line ###)
size(M) = 3  3
size(N) = 4  4
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Structures finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

