compare values in two workspace ?

조회 수: 7 (최근 30일)
Rakesh Praveen
Rakesh Praveen 2011년 12월 3일
i want to compare arrays of two different size(1 workspace with 1000x1 , other with 900x1) which contains data of type double stored in workspace. so that i check all d elements are equal or not ? how do i do it ?
thank you.

채택된 답변

Paulo Silva
Paulo Silva 2011년 12월 3일
So the question is just about comparing arrays of different sizes?
Maybe this way
a=ones(1000,1);
b=ones(900,1);
%b(10)=2; %change one element of b so a and b aren't equal
all(a(1:900)==b) %1 if they are equal and 0 if they aren't equal
It just compares the first 900 elements of a with those from b, the last 100 elements of a are just ignored
(I'm back after many weeks :) )
  댓글 수: 3
bym
bym 2011년 12월 3일
@Paulo -- welcome back
Paulo Silva
Paulo Silva 2011년 12월 3일
Hi proecsm, thanks for the welcome :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by