In Boolean algebra is X.(Y.Z) = (X.Y).(X.Z) - boolean

I know that X.(Y+Z) = X.Y+X.Z but does X.(Y.Z) = (X.Y).(X.Z) is true?
Please give me help.

Yes it is. X.(Y.Z) = (X.Y).(X.Z). Because X.X=X, one X on the RHS can be removed and we end up with the LHS.
(X.Y).(X.Z) = (X.X).(Y.Z) = (X).(Y.Z) = X.(Y.Z)
You can draw a truth table and verify it yourself.

Related

Report with side by side two images and a splited table - Matlab

I am trying in the code below to generate a report with side by side two images and a splited table but I get an error. Why this error occur?
Code:
close all;
clear all;
clc;
import mlreportgen.report.*
import mlreportgen.dom.*
import mlreportgen.utils.*
Name = {'A';'B';'C';'D';'E';'A';'B';'C';'D';'E'};
codeA = [8;3;8;0;4;8;3;8;0;4];
Height = [1;8;4;7;8;8;3;1;0;4];
Weight = [6;2;1;4;5;8;3;1;1;4];
T = table(Name,codeA,Height,Weight,codeA,Height,Weight,codeA,Height,Weight);
Image1 = Image(which('coins.png'));
Image2 = Image(which('sevilla.jpg'));
rpt = Report("myPDF","pdf");
imgStyle = {ScaleToFit(true)};
Image2.Style = imgStyle;
Image1.Style = imgStyle;
lot = Table({Image2, ' ', Image1});
lot.entry(1,1).Style = {Width('3.2in'), Height('3in')};
lot.entry(1,2).Style = {Width('.2in'), Height('3in')};
lot.entry(1,3).Style = {Width('3.2in'), Height('3in')};
lot.Style = {ResizeToFitContents(false), Width('100%')};
add(rpt, lot);
chapter = Chapter("Title",'Table Report');
table = FormalTable(T);
table.Border = 'Solid';
table.RowSep = 'Solid';
table.ColSep = 'Solid';
para = Paragraph(['The table is sliced into two tables, '...
'with the first column repeating in each table.']);
para.Style = {OuterMargin('0in','0in','0in','12pt')};
para.FontSize = '14pt';
add(chapter,para)
slicer = TableSlicer("Table",table,"MaxCols",5,"RepeatCols",1);
totcols = slicer.MaxCols - slicer.RepeatCols;
slices = slicer.slice();
for slice=slices
str = sprintf('%d repeating column and up to %d more columns',...
slicer.RepeatCols,totcols);
para = Paragraph(str);
para.Bold = true;
add(chapter,para)
add(chapter,slice.Table)
end
add(rpt,chapter)
close(rpt)
rptview(rpt)
Error:
*Index exceeds the number of array elements. Index must not exceed 10.
Error in try1 (line 26)
lot.entry(1,1).Style = {Width('3.2in'), Height('3in')};*
You define the variable
Height = [1;8;4;7;8;8;3;1;0;4];
Then you try and use the report gen function Height
lot.entry(1,1).Style = {Width('3.2in'), Height('3in')};
Because you've shadowed the Height function with a variable, MATLAB is trying to get the element of this array at index '3in', which is either nonsensical or (via some implicit ASCII conversion) is way out of range.
Per my comment on your previous question, I think the way the documentation suggests the report gen functions are imported is bad practice. By using import mlreportgen.dom.* you are putting all of the nicely name-spaced functions from that package into the common area, and in this case it has caused an unclear clash between two things. So there are two options:
Use the namespaced version of Height (and Width), if you did this with all of the report gen functions you would not need the import. The nice side-effect is you get tab-completion when typing the various functions from this package
lot.entry(1,1).Style = {mlreportgen.dom.Width('3.2in'), mlreportgen.dom.Height('3in')};
Sure, you code is longer, but it is more explicit.
... or ...
Simply don't define a variable called Height. Rename this and everything else can stay the same.

Int into label SpriteKit SKView, hl

I just want to know if is it possible to make a label or anything else who will be a integer and to display it to my gameview.
var pvElf = SKLabelNode(fontNamed:"Chalkduster")
pvElf.text = "100";
pvElf.fontSize = 45;
pvElf.position = CGPoint(x:370, y:600)
pvElf.zPosition = 2
addChild(pvElf)
I want pvElf to be an int but I don't find an SKIntNode or anything else. Because I want to decrease this number when I do an action. But if this is a label I can't.
Thank you very much !
Simply update the label's text with the Int (converted to a String).
let someInt = 4
pvElf.text = "\(someInt)"

How to add new rows (loop) in a table without overwritting

I'm extremely new to Matlab. Sorry if it's a simple question..
I'm trying to write a loop to add new rows.
files = dir('*.mat');
for ii=1:numel(files)
file = files(ii);
Variable = str;
Correlation = RCDvsMOVRAW;
Signification = pRCDvsMOVRAW;
Lag = lagDiff;
T = table(Correlation,Signification,Lag,'RowNames',Variable);
end
Thank you so much in advance.
Maybe this is what you're looking for:
files = dir('*.mat');
for K=1:numel(files)
file = files(K);
mat = load(file.name);
Variable = {mat.str};
Correlation = mat.RCDvsMOVRAW;
Signification = mat.pRCDvsMOVRAW;
Lag = mat.lagDiff;
T2(K,:) = table(Variable,Correlation,Signification,Lag);
end
writetable(T2)
Hope this helps

Is there any way to display numerous output neatly in Matlab?

Suppose I have numerous number of outputs and I want them to show as follow
Friction factor = xxx
Load factor = xxx
Thermal factor = xxxx
Is there any way to make the equal sign '=' align to each other? I've tried using the 'fprintf' function with '\t'. However, it's tough for me to achieve such arrangement.
Sincerely thank you for all the helps.
You could do the following:
names = {'Friction Factor','Load Factor','Thermal Factor'};
values = [xx,yy,zz];
nameLength = cellfun(#numel,names);
format = sprintf('%%-%is = %%f\\n',max(nameLength));
for n = 1:length(names)
fprintf(format,names{n},values(n));
end
What about this:
disp(['Friction factor = ' num2str(xxx)])
disp(['Load factor = ' num2str(yyy)])
disp(['Thermal factor = ' num2str(zzz)])

how can i swap value of two variables without third one in objective c

hey guys i want your suggestion that how can change value of two variables without 3rd one. in objective cc.
is there any way so please inform me,
it can be done in any language. x and y are 2 variables and we want to swap them
{
//lets say x , y are 1 ,2
x = x + y; // 1+2 =3
y = x - y; // 3 -2 = 1
x = x -y; // 3-1 = 2;
}
you can use these equation in any language to achieve this
Do you mean exchange the value of two variables, as in the XOR swap algorithm? Unless you're trying to answer a pointless interview question, programming in assembly language, or competing in the IOCCC, don't bother. A good optimizing compiler will probably handle the standard tmp = a; a = b; b = tmp; better than whatever trick you might come up with.
If you are doing one of those things (or are just curious), see the Wikipedia article for more info.
As far as number is concerned you can swap numbers in any language without using the third one whether it's java, objective-C OR C/C++,
For more info
Potential Problem in "Swapping values of two variables without using a third variable"
Since this is explicitly for iPhone, you can use the ARM instruction SWP, but it's almost inconceivable why you'd want to. The complier is much, much better at this kind of optimization. If you just want to avoid the temporary variable in code, write an inline function to handle it. The compiler will optimize it away if it can be done more efficiently.
NSString * first = #"bharath";
NSString * second = #"raj";
first = [NSString stringWithFormat:#"%#%#",first,second];
NSRange needleRange = NSMakeRange(0,
first.length - second.length);
second = [first substringWithRange:needleRange];
first = [first substringFromIndex:second.length];
NSLog(#"first---> %#, Second---> %#",first,second);