compare 1D array with rows of 2D matrix

how to compare entries of 1D array with rows of 2D matrix. entries of 1D array are the row number of 2D matrix. after comparing we write the corresponding column value of that row and if the row number gets repeat in 1D array then we move to next column value of same row and it goes on.I need help with code

回答 (2 件)

KSSV
KSSV 2018 年 9 月 25 日

0 投票

Read about ismember

3 件のコメント

Muhammad Sohail Abid
Muhammad Sohail Abid 2018 年 9 月 25 日
it only gives logical array. I want to check the row and then write the corresponding column value for that array entry
KSSV
KSSV 2018 年 9 月 25 日
logical indexing is powerful and very fast...o get the position/ index use find.
Muhammad Sohail Abid
Muhammad Sohail Abid 2018 年 9 月 28 日
Sir I have used trying index and ismember, but not able to find any of the result can you please make a code for relating image pixel values with points on table. here is the code which I made
here is code
disp('y^2 = x^3 + 5376x + 2438 mod 123457')
a=0:123456;
left_side = mod(a.^2,123457);
right_side = mod(a.^3+5376*a+2438,123457);
points = [];
for i = 1:length(right_side)
I = find(left_side == right_side(i));
for j=1:length(I)
points = [points;a(i),a(I(j))];
end
end
plot(points(:,1),points(:,2),'ro')
set(gca,'XTick',0:1:123456)
set(gca,'YTick',0:1:123456)
grid on;
pad_needed = 256 - (mod(size(points,1) - 1, 256) + 1);
if pad_needed > 0
points(end+pad_needed,:) = 0;
end
T = points;
Z = reshape(T,256,482,2);
img=rgb2gray(imread('lena.jpg'));
V=img(:);
V=V';

サインインしてコメントする。

Alishba
Alishba 2024 年 12 月 2 日
編集済み: Alishba 2024 年 12 月 2 日

0 投票

write similarities and dissimilarities between 1d and 2d array in matlab.

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

製品

リリース

R2013a

タグ

質問済み:

2018 年 9 月 25 日

編集済み:

2024 年 12 月 2 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by