confusion for how to use switch with multiple inputs
Show older comments
Hi, I have a gui which has two popup windows to identify which type of data is being used. Each of the two data types comes from a different test, so the x axis measures different quantities, there are two option types, so two popups each with 2 options.
I have the code to switch and plot either one type or another into an axis and that works, but i want to be able to overlay(plot two sets of data) on a different axes, for this I must be using the same type of data. At the moment I can do it for when both inputs are using one type of data, but I do not know the logic to plot when both data types are the same AND how to determine which type they are. I have played around with some very basic data and got nowhere, then thought an XNOR would tell me when both inputs were the same, but it doesn't tell me which type.
Any ideas or does this all need rewording to clarify?
clear all
close all
clc
A=[0 0 1 1];
B=[0 1 0 1];
A=A';
B=B';
C=logical(horzcat(A,B))
for k=1:4
if C(k,1)& C(k,2) ==0
C(k,:)
disp 'all inputs low'
elseif C(k,1)& C(k,2) ==~1
C(k,:)
disp ' inputs not same'
elseif C(k,1) & (C(k,2)) ==~0
C(k,:)
disp ' inputs not same'
else C(k,1) & C(k,2) ==1;
C(k,:)
disp 'all inputs high'
end
end
D=~xor(A,B)%XNOR
It gives the following results which confuse me as it is telling me all inputs are high when the inputs are 0,1 respectively.
C =
4×2 logical array
0 0
0 1
1 0
1 1
ans =
1×2 logical array
0 0
all inputs high
ans =
1×2 logical array
0 1
all inputs high
ans =
1×2 logical array
1 0
all inputs low
ans =
1×2 logical array
1 1
inputs not same
D =
4×1 logical array
1
0
0
1
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!