Error using ones Size inputs must be integers?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
hello every one i have a problem with my code for error
r =[zeros(size(img2,1),size(img2,2)) ones(size(img2,1),size(img2,2)/2)];
where img2 an image of size (111 235)
Error using ones
Size inputs must be integers
and i want to have an image of the same size of img2
採用された回答
Walter Roberson
2019 年 11 月 19 日
If you want an image the same size as img2 then
r = zeros(size(img2), class(img2));
after which you can assign ones into an appropriate section of r
Your phrase size(img2,2)/2 has a problem when the number of columns in img2 is odd, as it does happen to be. 235/2 is not an integer.
r(round(end/2)+1:end, round(end/2)+1:end) = 1; %perhaps
10 件のコメント
youb mr
2019 年 11 月 19 日
it's work but i want to have an image that the left side a black side and the rhigt side a white side
Walter Roberson
2019 年 11 月 19 日
r(:, round(end/2)+1:end) = 1; %perhaps
youb mr
2019 年 11 月 19 日
Error using round
Not enough input arguments.
Walter Roberson
2019 年 11 月 19 日
>> img2 = rand([111 235]);
>> r = zeros(size(img2), class(img2));
>> r(:, round(end/2)+1:end) = 1; %perhaps
>> imshow(r)
Works for me.
What shows up for
which round
youb mr
2019 年 11 月 19 日
Error using round
Not enough input arguments.
Error in Untitled (line 3)
r(:, round(end/2)+1:end) = 1; %perhaps
Walter Roberson
2019 年 11 月 20 日
suggests that you might be running into bugs with old versions of MATLAB, in the R2011 time frame. Which MATLAB version are you using?
youb mr
2019 年 11 月 20 日
i use R2018
Walter Roberson
2019 年 11 月 20 日
r(:, ceil(end/2)+1:end) = 1; %perhaps
vishnu vvs
2020 年 3 月 17 日
hi everyone in my code i have an error please help me out
Error using zeros
size inputs must be integers.
error in two _stage _sub
Q_phase = zeros (Nr,1) ;
ERROR IN main_SR
[AP1,DP1,p0] = two_stage_sub(H,K,bit,p);
Walter Roberson
2020 年 3 月 17 日
You might have computed Nr using floating point arithmetic such as 0.35/0.001. If so... Don't Do That! Floating point computations are only approximate when decimal fractions are used.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
