I want to display matrices Yn (5x5), Un(5x1), Jn(5x1) in a format: Yn * Un = Jn, like this:
multiply_sign = [ nan; nan; '*'; nan; nan ];
equals_sign = [ nan; nan; '='; nan; nan ];
YnUnJn = [Yn, multiply_sign, Un, equals_sign, Jn]
I get an error, that the '*' and '=' vectors are char-arrays and Yn,Un,Jn are numeric-arrays. Is there perhaps a way to get round it?
In matlab it's possible to use uitable, but it's not implemented in Octave.
Input are Yn, Un, Jn matrix'es with dimention as specified above.
Output is YnUnJn matrix or whatever that looks like specified format: matrix Yn, then the "*" sign, then Un, then "=" sign, then Jn matrix.
Like this:
Here is a basic implementation in Octave. Note that disp
function in octave returns a string.
Yn = rand(5)-.5;
Un = rand(5,1)-.5;
Jn = rand(5,1)-.5;
b = blanks(size(Yn ,1));
dsp=@(x)char(strsplit(disp(x),'\n'));
multiply_sign = strjust(['*' b],'center').';
equals_sign = strjust(['=' b],'center').';
disp([dsp(Yn) multiply_sign dsp(Un) equals_sign dsp(Jn)])
0.1610588 0.1244556 -0.2046512 -0.1799725 -0.3302048 0.364565 0.167053
-0.1774412 0.3618586 0.4974047 0.4349322 -0.4689669 -0.013163 -0.442009
0.1016794 -0.0991844 0.4728800 0.2046589 -0.2876299* 0.091990= 0.405725
-0.2048010 -0.4256928 -0.0517186 0.2915129 -0.3435698 -0.376725 0.342397
-0.2740378 -0.0907411 0.0090493 0.4677547 -0.2294902 -0.136846 0.096984
.
In MATLAB you may need to use evalc('disp(Yn)')
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.