I am just beginning to learn Matlab, so this question might be very basic:
I have a variable
a=[2.3 3.422 -6.121 9 4.55]
I want the values to be output to a .txt file like this:
2.3
3.422
-6.121
9
4.55
How can I do this?
fid = fopen('c:\\coeffs.txt','w'); //this opens the file
//now how to print 'a' to the file??
...
I have a text file (c:\input.txt) which has:
2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0 2048.0 4096.0 8192.0
In Matlab, I want to read it as:
data = [2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0 2048.0 4096.0 8192.0]
I tried this code:
fid=fopen('c:\\input.txt','rb');
data = fread(fid, inf, 'float');
data
but I a...
I copied the matlab_xunit folder to C:\Program Files, and included it (and its subfolders) on the MATLAB path. Now MATLAB recognizes new commands such as
runtests
But this command does not find any tests on the current folder. What I have done wrong? What else can I do?
>> runtests
Starting test run with 0 test cases.
PASSED in 0.0...
Usually when you print a string in MATLAB:
disp('this will print black letters')
Can it be printed in color instead?
...
I've got two new-style Matlab classes - B & C, both concrete subclasses of an abstract parent, A. A is a subclass of hgsetset (handle class). I'd like to put them in an array in Matlab, and treat them both as A's. They are defined, roughly, as:
classdef A <hgsetget
methods
function foo(this)
%does some common stuff, then
...
Hi, I have a 4-core processor and have a recursive Matlab function which makes four recursive calls:
function J = do_stuff(I)
if some_condition(I)
J = blah_blah(I);
else
[I1,I2,I3,I4] = split4(I);
J1 = do_stuff(I1);
J2 = do_stuff(I2);
J3 = do_stuff(I3);
J4 = do_stuff(I4);
J = join4(J1,J2,J3,J4);
end
Is t...
I created a gui with MATLAB's GUI Builder. After some changing around, an image of an old plot is still loaded into the gui on start up. How can I tell MATLAB to disregard that old plot?
I added a toolbar by adding
set(hObject,'toolbar','figure');
into the "gui_OpeningFcn". Now I decided that I don't want the toolbar in my gui any ...
I have several Gb of sample data captured 'in-the-field' at 48ksps using an NI Data Acquisition module. I would like to create a WAV file from this data.
I have done this previously using MATLAB to load the data, normalise it to the 16bit PCM range, and then write it out as a WAV file. However MATLAB baulks at the file size as it does ...
I would like to receive the input for my MATLAB program from an USB source. It is possible? How? I am also the developer of the hardware that sends an audio stream through the USB. There is any way to send this kind of data it making easier to receive it?
...
I just can't find it. How to set up axis and labels in matlab so they cross at zero point, with the labels just below the axis not on left/bottom of the plot ?
If I didn't make myself clear - I just want the plot to look like like we all used to draw it when in school. Axes crossing, 4 quadrants, labels right below axis, curve ... as it...
I'm a MATLAB beginner and I would like to know how I can acquire and save 20 images at 5 second intervals from my camera. Thank you very much.
...
Comparing Visual Studio code completion with MATLAB R2008b 7.7 there are a few important features missing in the last one:
Local variables completion
Function, for, if auto ENDing
But Visual Studio doesn't support MATLAB code. Is there any MATLAB plugin, editor or version with a better code completion?
...
I deployed a MATLAB project into a DLL, to be called from C++, and it works just fine. Happy days.
But what happens when the user asks to cancel an operation?
I tried creating a global variable named UserAborted. I initialize it to 0 before running the long function in MATLAB. I also wrote the following two functions:
function AbortIf...
According to "How to Write Tests That Share Common Set-Up Code" is it possible to:
function test_suite = testSetupExample
initTestSuite;
function fh = setup
fh = figure;
function teardown(fh)
delete(fh);
function testColormapColumns(fh)
assertEqual(size(get(fh, 'Colormap'), 2), 3);
function testPointer(fh)
assertEqual(get(fh, '...
With a sine input, I tried to modify it's frequency cutting some lower frequencies in the spectrum, shifting the main frequency towards zero. As the signal is not fftshifted I tried to do that by eliminating some samples at the begin and at the end of the fft vector:
interval = 1;
samplingFrequency = 44100;
signalFrequency = 440;
sample...
I have this problem that has been bothering me for quite a while.. I want to change the format of the number.. Don`t know how? Ive tried the help files but can't find the answer.. If you can help me please do..
...
I read the: How to create a buffer matrix in MATLAB for continuous measurements?, question. I wanted to know if its possible to store values in sequence instead of in reverse as in the question, without resorting to fliplr (flip left to right) after each iteration?
...
It seems you need a license to use MATLAB. I do not have one so I was wondering if there was some highly-compatible substitute for it in Linux.
...
In Matlab (Neural Network Toolbox + Image Processing Toolbox), I have written a script to extract features from images and construct a "feature vector". My problem is that some features have more data than others. I don't want these features to have more significance than others with less data.
For example, I might have a feature vecto...
I am drawing a graph using the plot() function, but by default it doesn't show the axes.
How do we enable showing the axes at x=0 and y=0 on the graph?
Actually my graph is something like:
And I want a horizontal line corresponding to y=0. How do I get that?
...