Hi...can we create a variable "a" with double array type ? . Thank.

i did tried commands : str2num,str2double...but it not true

3 件のコメント

Jan
Jan 2017 年 10 月 12 日
The question seems to be clear, but in the discussion we see, that you want something else. It seems like you have confused numeric and symbolic variables. So please edit the question and add more details of what you want to achieve.
super bad
super bad 2017 年 10 月 12 日
thank bro.. I am from Vietnam, my English is not good.
Jan
Jan 2017 年 10 月 12 日
Your English is fine enough to explain the problem with more details. I'm not a native English speaker also, like many other users of this forum. Beside the language, it is difficult to explain a problem in general, because as long as it is not solved, it is not clear, which parts are relevant or not. Simply try to explain it again with more details. Prefer to edit the question, such that the reader find all details in one location.
I'm not "bro", but I have a name: "Jan". I assume, the other persons in the forum not "bros" also. ;-)

サインインしてコメントする。

回答 (3 件)

Adam
Adam 2017 年 10 月 12 日

1 投票

a = 7;
is a variable 'a' of type double.
Or even
a = [];
is also type double, but with empty contents.

1 件のコメント

super bad
super bad 2017 年 10 月 12 日
No bro It is not so easy. I want to create a matrix has value is 'a'. 'a' function is like a number and in the form of double array in class...can we do it?

サインインしてコメントする。

John D'Errico
John D'Errico 2017 年 10 月 12 日
編集済み: John D'Errico 2017 年 10 月 12 日

1 投票

You want to create an array that has double precision class, thus a "double", but contains a string, 'a'.
Sorry, but you cannot do so. A double can contain ONLY numbers. Those elements must all be of class double.
If you create an array that contains a string, 'a', it must be either of class char, or a cell array.
A = 'a'
A =
'a'
B = {'a'}
B =
1×1 cell array
{'a'}
whos
Name Size Bytes Class Attributes
A 1x1 2 char
B 1x1 114 cell

7 件のコメント

Guillaume
Guillaume 2017 年 10 月 12 日
編集済み: Guillaume 2017 年 10 月 12 日
it must be either of class char, or a cell array
or, as of R2016b, a string:
C = string('a'); %R2016b
C = "a"; %R2017a or later
super bad
super bad 2017 年 10 月 12 日
thank bro. And you know how to create a tranfer function like this?
s + a
--------
s + b
without using the command ( pretty).
Jan
Jan 2017 年 10 月 12 日
I depends: How do you want to use this function? Please explain more details.
super bad
super bad 2017 年 10 月 12 日
s + a
--------
s + b
it is a transfer function , we can ( +, -, * / ) it with other tranfer function. i think we can't do it. But it is my test.
Image Analyst
Image Analyst 2017 年 10 月 12 日
Try this:
function result = MyTransferFunctions, a, b)
result = (s+a)./(s+b)
You pass in s, a, and b of course. If that's not right, then let's finally get an explanation that is clear, preferably with some numerical examples.
super bad
super bad 2017 年 10 月 12 日
a,b is the coefficient in front of s , if (a or b) is a string or symbol then we were wrong
Jan
Jan 2017 年 10 月 12 日
@super bad: This sound really magic. I still do not have any idea, what you are talking about. What is "a", "b" and "s"? What are your inputs, what is the wanted output and which problem do you try to solve? Why do you want to operate on "strings", "symbols" (what ever this is) and numerical matrices at the same time?

サインインしてコメントする。

Mridul Gandhi
Mridul Gandhi 2019 年 6 月 9 日

0 投票

Maybe you mean this:
I=5;
J=5;
a=sym('a',[I J]);
Creates variable 'a' of size (IxJ):
a =
[ a1_1, a1_2, a1_3, a1_4, a1_5]
[ a2_1, a2_2, a2_3, a2_4, a2_5]
[ a3_1, a3_2, a3_3, a3_4, a3_5]
[ a4_1, a4_2, a4_3, a4_4, a4_5]
[ a5_1, a5_2, a5_3, a5_4, a5_5]

2 件のコメント

Thong Phan
Thong Phan 2021 年 1 月 25 日
Yes but each a1_i is not double type
Rik
Rik 2021 年 1 月 25 日
As detailed in several comments: that is not possible. There are many options of what you could mean in this thread. Which do you want?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeData Type Identification についてさらに検索

製品

質問済み:

2017 年 10 月 12 日

コメント済み:

Rik
2021 年 1 月 25 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by