Octave--compare two matrix
显示 更早的评论
How can I insert the row of matrix A into matrix M if the whole row of matrix A and matrix B are the same?
There is the example
>> A = [1 2; 3 4]
A =
1 2
3 4
>> B = [1 2; 3 6]
B =
1 2
3 6
M =
1 2
采纳的回答
M=A(ismember(A,B,"rows"),:)
7 个评论
Is use of double quotes defined in octave?? I do not know.
The octave experts are elsewhere, at a different resource. Octave is a different programming language and not a suitable question for MATLAB Answers.
Having been forced to use Octave lately due to not having Matlab available currently, I can answer Walter's question.
Double quoted strings are supported in Octave (and seem to be actually preferred as they are used almost exclusively in the documentation for things like fprintf). I still use single quotes for the most part, as that is what I got used to over the years in Matlab. Strings were just introduced when I lost access to Matlab and I never got into the habit of using them.
Walter is right, of course, that asking Octave questions in Matlab Answers isn't really appropriate.
I really do miss Matlab. :(
Thanks, Les.
Perhaps you could get a Home license?
M=A(ismember(A,B,"rows"),:) works in octave. However, if I also want to compare the column what should I do? I have check M=A(ismember(A,B," column"),:) doesn't work. I am new in using octave and I only have some knowledge on the primary function of creating a matrix and some simple calculations.
Transpose the data you send into ismember so that the column you want to compare becomes a row for the purpose of comparing.
Yeah, I got it!! Thanks, Roberson
Note that Matlab and Octave are sufficiently similar that basic tutorials will work for both. There are several places you can find the most important syntax differences. One of them you encountered here: single and double quotes are interchangeable in Octave, in Matlab they are not.
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Octave 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
