最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

北太天元畫矩陣非零元的腳本

2023-06-11 22:38 作者:盧朓  | 我要投稿

%draw_matrix.m 北太天元腳本函數(shù)

% 北太天元把矩陣中的非零元的位置畫出來

% A [input] 布爾矩陣或者double 矩陣,如果|A(i,j)| > eps 則填充紅色

%??非零元使用 |A(i,j)|>eps 來判定的

%例如

%clf

%close all

%clear all


%m = 3;

%n = 3;

%A = zeros(m,n);


%A(2,2) = 1.0;

%draw_matrix(A)


%

function??ok = draw_matrix(A)

???clf

???close all

???hold on;


???if isa(A,'double')

??????B?= abs(A) > eps;

???elseif islogical(A)

??????B = A

???else

??????ok = false;

??????error("A需要是布爾矩陣或者double矩陣");

???end


???[m,n] = size(A);


???for i=1:m

??????for j=1:n

?????????if(B(i,j))??????

????????????tiao_rectangle('Position',[i-1 j-1 1 1], 'Curvature', 0, 'FaceColor', [1,0,0], 'EdgeColor','m', 'LineWidth', 1)

?????????else


????????????tiao_rectangle('Position',[i-1 j-1 1 1], 'Curvature', 0, 'FaceColor', [0.9,0.9,0.9], 'EdgeColor','m', 'LineWidth', 1)

?????????end

??????end

???end

???hold off

???ok = true;

end


%Position[input]??總是寫成"Position"

%pos[input] 是一個1x4的矩陣 pos =[ 左下x, 左下y, 寬度, 高度]

%cur[input]?0 表示直角舉行

%fc[input]?填充的顏色

%lw[input] 邊的寬度

function ok = tiao_rectangle(Position, pos, Curvature, curv, FaceColor, fc, EdgeColor, ec, LineWidth, lw)

?len = length(curv);

?if (len >= 2)

???horz_curv = curv(1);

???vert_curv = curv(2);

?elseif (len == 1)

???horz_curv = curv(1);

???vert_curv = curv(1);

?else

???horz_curv = 0;

???vert_curv = 0;

?end


?lux = pos(1); luy =pos(2);

?width = pos(3); height = pos(4);



?if ( abs(horz_curv)<0.1 && abs(vert_curv) <0.1 )

???fx = [lux, lux+width, lux+width ,lux];

???fy = [luy, luy, luy+height, luy+height];

?else

???n = 15;

???p = pi / 2 * [0 : n] / n;

???c = curv .* pos(3:4) / 2;

???cx = c(1) * sin (p) - c(1);

???cy = c(2) * cos (p) - c(2);

???fx = [pos(1) - cx(n+1:-1:1), pos(1) + pos(3) + cx, ...

?????pos(1) + pos(3) + cx(n+1:-1:1), pos(1) - cx, pos(1)];

???fy = [pos(2) - cy(n+1:-1:1), pos(2) - cy, ...

?????pos(2) + pos(4) + cy(n+1:-1:1), ...

?????pos(2) + pos(4) + cy, pos(2) + c(2)];

?end


?fill(fx, fy, fc, EdgeColor, ec, LineWidth, lw)

?ok = true;

end



北太天元畫矩陣非零元的腳本的評論 (共 條)

分享到微博請遵守國家法律
土默特左旗| 北安市| 东港市| 郸城县| 福鼎市| 镇赉县| 舒城县| 玛纳斯县| 高邮市| 浮梁县| 五峰| 张家港市| 阳谷县| 基隆市| 郁南县| 晋城| 藁城市| 道真| 天柱县| 上思县| 康平县| 岳池县| 宁津县| 乌拉特中旗| 砚山县| 兖州市| 饶阳县| 高碑店市| 马龙县| 普定县| 土默特右旗| 平原县| 奎屯市| 西畴县| 恩平市| 宁明县| 宁波市| 通辽市| 西昌市| 合水县| 南昌市|