I was developing a math research programm in Racket using Graph Theory an I need to draw the datas. Is there a library to do it?
Example of graph:
‘((1 2) (1 7) (2 3) (3 2) (4 2) (7 4))
Desired output
Thank you in advance!
Use graph is allows you to draw graphs with the help of GraphViz.
http://docs.racket-lang.org/graph/index.html#%28part._.Graphviz%29
Related
I've got a silly question. I took a vector math class about 10 years ago and could've sworn I remembered an operation that allowed me to multiply the values of a vector together like so:
Vector3 v1 = new Vector3(1, 0, 2)
Vector3 v2 = new Vector3(5, 5, 5)
//Vector3 v3 = SomeVectorOperation(v1, v2) = (1 * 5, 0 * 5, 2 * 5)
Now in reviewing all my notes, and everything I can find online, it doesn't look like this is a common operation at all. Of course I can write a function that does it:
Vector3 VectorMult(Vector3 v1, Vector3 v2) {
return new Vector3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z);
}
So far I've found at least a few instances where an operation like this would be helpful, so I'm not sure why it wouldn't exist already in some form. So, I guess I have two questions:
Is there an easier way to get the result I'm looking for than making my own custom function?
Is there a reason why there is no standard vector operation like this to begin with?
Thank you very much for your time!
When we electrical engineers want to sound smart, we call it the Hadamard product, but otherwise it’s just the “element-wise product”.
What library are you using? GLSL? Eigen? GSL? We can look for how to do element-wise multiplication in it. (It can often be accelerated using SIMD, so an optimized implementation provided by a library will be faster than your hand-rolled function.)
Edit: Unity calls this Vector3.Scale: “Multiplies two vectors component-wise.”
This question already has an answer here:
read from a text file and load it into a matrix in matlab [duplicate]
(1 answer)
Closed 7 years ago.
Good day.
I would like to know how to load a .txt file in matlab. What I want is to work with text classification and guess the first thing to do is load devo my data in matlab .... but when I try to generate many files .my I just want an array containing my text.
Greetings and thanks in advance.
There's multiple functions that do that: importdata,textscan,fopen,dlmread etc.
I do not understand much from your question, but begin by reading through these documentation pages and try them to see which works best for you.
This question already has answers here:
How can I customize the positions of legend elements?
(5 answers)
Closed 4 years ago.
I use MATLAB to draw a graph. The legends are too big and cover a part of the graph. I want to split the entries of the legend in two columns. I saw some solutions on the net that explain how to change the functions to display the legend in multiple columns. However, my program reads the data from an Excel file and their solutions don't work for me. Could anybody please help me to solve this issue? Sorry if my question is naive, I'm not good in MATLAB.
Here is my code:
A=xlsread('C:\temp.xlsx','A1:A10');
B=xlsread('C:\temp.xlsx','B1:B10');
C=xlsread('C:\temp.xlsx','C1:C10');
D=xlsread('C:\temp.xlsx','D1:D10');
E=xlsread('C:\temp.xlsx','E1:E10');
F=xlsread('C:\temp.xlsx','F1:F10');
G=xlsread('C:\temp.xlsx','G1:G10');
plot(A,B,A,C,A,D,A,E,A,F,A,G)
hold on;
axis([10 100 -10 0])
xlabel('length')
ylabel('BER')
legend('AAAAAAAAAA','BBBBBBBBBB','CCCCCCCCCC','DDDDDDDDDD','EEEEEEEEEEE','FFFFFFFFFF')
Here are two different links to matlab-files that should solve your problem:
ColumnLegend
GridLegend
The creation of the legend should be independent on how you read your data, so the fact that you read your data from Excel should not give you any problems!
This question already has answers here:
How can I index a MATLAB array returned by a function without first assigning it to a local variable?
(9 answers)
Closed 8 years ago.
E.g. I have the output of cov(A,B), which is a 2×2 matrix.
I want to select the element in position 2,1 of the matrix.
I can do this by blah = cov(A,B) and then select blah(1,2).
This isn't the most efficient way to do it though, and I'd prefer to do it in one line. Is there a way to do that?
You can try using getfield():
getfield(cov(A,B), {1,2})
The performance difference between this and what you have currently will likely be negligible, however. I personally would prefer just using that temporary variable.
<stealing brilliance from Amro>
You can also do this:
C = builtin('_paren', cov(A,B), 2, 1);
</stealing brilliance from Amro>
This question already has answers here:
How to elegantly ignore some return values of a MATLAB function
(8 answers)
How do I get the second return value from a function without using temporary variables?
(2 answers)
Closed 9 years ago.
I'm not very good at programming and new to matlab, so sorry if I'm not using the right terminology.
If I use the e.g. fminbnd procedure in Matlab first i get the x-value which minimises and then i get the function value. Is there a neat way for me to get just the minimum function value.
To make it clear, for me it seems I have to do:
[x,y] = fminbnd(h,-10,10)
when I only need y. Is there any way for me to not get x?
Use ~ to suppress x output. Only available in later versions of matlab (=> r2009b).
[~, y] = fminbnd(h, -10, 10);