Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I've working on a problem which involves creating a SVG file. I've written a VM. My own VM program reads in a string of single character "commands" on stdin using the VM getc instruction. Using these commands it then generates a graphics file in SVG format as output.
Below are six examples of input command strings:
RULDX
PRUPRULDX
PRRUPCBEAX
PRUP J R K PRP JJJJJ R KKKKK PRP JJJJJJJJJ R X
PRUP M U N PUP MMMMM U NNNNN PUP MMMMMMMMM U X
PRUP KKKKKKKKKK KKKKKKKKKK NNNNNNNNNN A X
As far as I've read these strings aren't related to SVG coding or atleast I can't find any relation at all.And I need to use these commands to draw some 2d open figure with lines.
To complete another bigger task I must first determine what the commands demonstrated above do.Please help me in this crossing this hurdle. Do tell me if I didn't explain it well. I doubt my explanation because I myself wasn't able to understand! Thanks in advance !! :D
RULDX seems to be a square (Right Up Left Down) and a X to terminate the input (eXecute?)
See logo for a similar example how to make such drawings.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have an array of structs. Every struct holds a set of data for one single measure. Matlab gives me an error when I try to plot this data.
Expected one output from a curly brace or dot indexing expression, but there were 361 results.
How should I rewrite my plot code?
plot(result.structArray_A(:).nonArrayValue_X, result.structArray_A(:).nonArrayValue_Y);
I have found a solution. Simply writing the following does work, even if the syntax does look odd:
plot([result.structArray_A.nonArrayValue_X], [result.structArray_A.nonArrayValue_Y]);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I took this from the Matlab help section:
text(size(I,2),size(I,1)+15, ...
'Image courtesy of Massachusetts Institute of Technology', ...
'FontSize',7,'HorizontalAlignment','right');
I don't understand how it works, could anyone explain it to me?
https://www.mathworks.com/help/matlab/ref/text.html
In summary:
x = size(I,2)
y = size(I,1)+15
"..." is just the statmentment line continuation character in matlab (it is basically saying, do not end this statement here, but rather continue reading next line)
actual text = 'Image courtesy of Massachusetts Institute of Technology'
The next 4 arguments are name-value pairs (as described in the link above). Basically, it allows you to grab a particular setting and apply it a value based on its name.
font size is set to 7 and horizontal alignment is set to right.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
I'm really new to MATLAB and have to implement some functions. To start, I'm supposed to make a function about a mean square error, for which I have the following formula:
My goal is to implement this in MATLAB. I've tried to analyse this for days, but I'm still lost. I guess the first thing to do is to create a function and then put all of the calculations. Should I declare variables like N though? Or can I just use them in the calculations without declaring? I'm just looking for some advises that would help me get started, I have no one else to ask about this, so a short guide/tips on how to take down this particular example would be amazing. Thank you in advance!
For a mean square error you need two inputs, Y and Y_bar and one output E. You don't need to declare N because it is implied by the length of each of your inputs. I'm going to assume that your inputs are both column vectors and are the same length.
function E = MSE(Y, Y_bar)
N = size(Y,1);
E = sum((Y-Y_bar).^2)/N
end
You should save this code a an .m file named mse.m and make sure it is in your working directory. If you don't know what that means, you need to look it up.
This is extremely basic MATLAB though, before you continue with anything, I think you should start by working through some beginners guides. As mentioned, stackoverflow is not the place to learn the very basics of a programming language.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
i keep getting the error "Error using -""Matrix dimensions must agree"
for this piece of code. Can anybody help me and identify where i'm going wrong? I should be getting 8 plots of f vs d.
P=500;
N=1:1:8;
a=-0.4;
b=-1;
Kd=700;
d50star=(1./(10.^(Kd*(N.^a)*(P-115).^b)))
w0=0.45;
d=0:0.1:10
d50N0=5;
if d50star < 0.33;
w=(1-(2.3*d50star))*w0
else
w=(3.4-(5.5*d50star))*w0
end
d50=(1-d50star)*d50N0;
f=1-(1./((1+exp((d-d50)/w))))
There are at least two errors in the script:
1) in the last line [f=1-(1./((1+exp((d-d50)/w))))]
d size is 1x101
d50 size is 1x8
The size inconsistency is related to the definition of:
N=1:1:8; and
d=0:0.1:10
2) depending on the algoroth, it could be ./w instead of /w
Hope this helps.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
In my matlab program i am reading the data file using fscanf and writing the the code code to read all the values.That makes me write several steps.
How to use Load() function to overcome this ad make it simple.
So the way load works is to load variables from MATLAB binary/ascii files. In order to create said files you'll have to use the save function e.g.
octave:3> T = "Hello"
T = Hello
octave:4> save "-binary" "testfile" T
octave:5> clear
octave:6> T
error: 'T' undefined near line 1 column 1
octave:6> load "-binary" "testfile" T
octave:7> T
T = Hello
octave:8>
Sorry I used octave for the example but it's the same code either way. So if you know your going to be using the same data just save it in a MATLAB's binary format. It should save your self the time of having to use fscanf on it next time your playing around with the data.