From: Pasi on
Hi!

How can I c+p matlab arrays (very large) to c code? Can I write it to
some file in matlab? Like:

in matlab
---
>> S=[1 2 3 4 5;2 3 4 5 6]

S =

1 2 3 4 5
2 3 4 5 6
---

In c:
---
int S[2][5] ={
{1, 2, 3, 4, 5},
{2, 3, 4, 5, 6}
};
---

If I c+p directly this text from matlab to c code, I have very much to
the doing.
From: Tim Wescott on
Pasi wrote:

> Hi!
>
> How can I c+p matlab arrays (very large) to c code? Can I write it to
> some file in matlab? Like:
>
> in matlab
> ---
> >> S=[1 2 3 4 5;2 3 4 5 6]
>
> S =
>
> 1 2 3 4 5
> 2 3 4 5 6
> ---
>
> In c:
> ---
> int S[2][5] ={
> {1, 2, 3, 4, 5},
> {2, 3, 4, 5, 6}
> };
> ---
>
> If I c+p directly this text from matlab to c code, I have very much to
> the doing.

"c+p"?

Look to see what kind of formatted printing facilities Matlab has --
it'll probably be named "printf" or "fprintf" and you should be able to
output in whatever language you want.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
From: Pasi on
Tim Wescott wrote:
> Pasi wrote:
>
>> Hi!
>>
>> How can I c+p matlab arrays (very large) to c code? Can I write it to
>> some file in matlab? Like:
>>
>> in matlab
>> ---
>> >> S=[1 2 3 4 5;2 3 4 5 6]
>>
>> S =
>>
>> 1 2 3 4 5
>> 2 3 4 5 6
>> ---
>>
>> In c:
>> ---
>> int S[2][5] ={
>> {1, 2, 3, 4, 5},
>> {2, 3, 4, 5, 6}
>> };
>> ---
>>
>> If I c+p directly this text from matlab to c code, I have very much to
>> the doing.
>
>
> "c+p"?
>

Copy and paste.
From: Bhaskar Thiagarajan on
"Pasi" <pasi(a)pa.si> wrote in message news:d1a7pr$6fq$2(a)plaza.suomi.net...
> Hi!
>
> How can I c+p matlab arrays (very large) to c code? Can I write it to
> some file in matlab? Like:

Pray tell what 'c+p' is?

> in matlab
> ---
> >> S=[1 2 3 4 5;2 3 4 5 6]
>
> S =
>
> 1 2 3 4 5
> 2 3 4 5 6
> ---
>
> In c:
> ---
> int S[2][5] ={
> {1, 2, 3, 4, 5},
> {2, 3, 4, 5, 6}
> };
> ---
>
> If I c+p directly this text from matlab to c code, I have very much to
> the doing.

Well, you can open a file pointer in matlab, use fprintf (and its variants)
to write to the file in a form that is suitable for C.
Look up fopen, fprintf in the matlab help files for details.

You should also be asking this in the matlab newsgroup (perhaps only there).
comp.soft-sys.matlab

Cheers
Bhaskar


From: Jaime Andr�s Aranguren Cardona on
As Tim wrote, fprintf is the function to use. You'd had to write your own
script, though (but that's not too complicated)

--
------------------------------
Jaime Andrýs Aranguren Cardona
jaac(a)sanjaac.com
SanJaaC Electronics
Soluciones en DSP
www.sanjaac.com


"Pasi" <pasi(a)pa.si> escribiý en el mensaje
news:d1a8v5$7n9$1(a)plaza.suomi.net...
> Tim Wescott wrote:
>> Pasi wrote:
>>
>>> Hi!
>>>
>>> How can I c+p matlab arrays (very large) to c code? Can I write it to
>>> some file in matlab? Like:
>>>
>>> in matlab
>>> ---
>>> >> S=[1 2 3 4 5;2 3 4 5 6]
>>>
>>> S =
>>>
>>> 1 2 3 4 5
>>> 2 3 4 5 6
>>> ---
>>>
>>> In c:
>>> ---
>>> int S[2][5] ={
>>> {1, 2, 3, 4, 5},
>>> {2, 3, 4, 5, 6}
>>> };
>>> ---
>>>
>>> If I c+p directly this text from matlab to c code, I have very much to
>>> the doing.
>>
>>
>> "c+p"?
>>
>
> Copy and paste.


 | 
Pages: 1
Prev: Matlab for Dummies
Next: Configure EClkOut